🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Animating characters on sloping ground

Started by
7 comments, last by lawnjelly 6 years, 5 months ago

Anyone have any suggestions for ways of animating characters on varying slopes on landscapes? I've no idea what are standard ways of dealing with this, and have been putting this off to some extent. The issues are mainly with larger animals cutting through the terrain on slopes.

elephants2.jpg.bde85e4247bea9227a7540faf5bda775.jpg

I've tried raising animals up higher above the land, but they look obviously 'in the air' in certain positions. I've also tried putting 2 land height probes at the front and rear, so that they change height according to their orientation, but that looks silly with strange changes in elevation as they move. I've also tried changing the pitch angle when rendered, this looks a bit silly (but not out of question lol).

Another possibility is to turn off depth testing against the landscape, but I would have to figure a way of still having it working when they are behind mountains. Perhaps if I push back the depth value of the land this will work.

I have read this article on mechwarrior 4:
https://www.gamasutra.com/view/feature/131863/animation_blending_achieving_.php

and I see they deal with it by having a flat animation, left and right and up and down slope animations, and blending between them. I can do this, but it sounds like a lot of extra animations for a one man team, and it also means I'd probably have to use a lower / upper body split for all animations, rather than be able to use full body. Plus use some performance for the blending (this is on mobiles).

I've not really used IK before in game, is this a realistic / practical solution? Or can I use a simpler system, make some standard poses on flat, and slopes, then measure knee etc angle offset, then blend in these offsets with some scaling at runtime to make the legs more bent or extended?

croc.jpg.f1afe806dc88ab22ec152e3b806d9603.jpg

Another solution is to just design around the problem and make the large animals only able to move over flat ground. I guess this is more what happens in real life, I haven't seen many crocodiles climbing up slopes on nature progs lol.

Any thoughts, experiences on this would be welcome. :)

 

Advertisement

Maybe having an up-vector for the models that points in the same direction of the face normal of the underlying polygon? And Orientate your model to coincide with that?

10 hours ago, markypooch said:

Maybe having an up-vector for the models that points in the same direction of the face normal of the underlying polygon? And Orientate your model to coincide with that?

I did try this (just with pitch rather than taking into account roll, but the effect was similar). It 'kinda' works but it looks a bit wierd (as gravity no longer seems to be pointing downward). I guess I may end up partly using a milder version of this as part of a solution.

I don't think there is any "standard" way and as far as I know stuff can get very fancy there. Take for example HumanIK which dynamically adjust the model and has been used in many AAA games : 

 

On 1/28/2018 at 2:05 PM, lawnjelly said:

Any thoughts, experiences on this would be welcome.

There is a old trick for this.

You attach a sphere collider at the bottom of the rig. The sphere tilts the model and the back legs blocks the fall.

You can then use ray cast to move the legs to the surface and all kinds of fancy tricks. Here is a ugly example I made in Blender just to show the concept:

Sphere.thumb.jpg.6acc99f26deb7aec1589559fb4b61a66.jpg

Search for : Sphere collider align to terrain

Or something like that, this is a very old and well used trick.

 

Thanks guys! I've found some IK example source code and it doesn't look as frightening as I feared. So I'll try and have a go when I get some spare time! :)

5 hours ago, lawnjelly said:

Thanks guys! I've found some IK example source code and it doesn't look as frightening as I feared. So I'll try and have a go when I get some spare time! :)

Post the link(s) if they're available for others in the future that use this thread :)

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

https://www.youtube.com/watch?v=2772HKIsf1M

http://www.darwin3d.com/gdm1998.htm

It turns out I'd actually done stuff similar to the CCD algorithm in the past.. although the constraints will be fun, one suggestion was to convert to euler angles, do the constraints, than back to quaternions. First I'll try the 2 bone analytical solution though, as it might work for leg heights and I would guess is the most efficient.

It has inspired me I might use a similar technique to animate the snake in game! :)

This topic is closed to new replies.

Advertisement