Jump to content
  • Advertisement
lawnjelly

Animating characters on sloping ground

Recommended Posts

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. :)

 

Edited by lawnjelly

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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 : 

 

Edited by ChuckNovice

Share this post


Link to post
Share on other sites
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.

 

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

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! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!