Adaptive Animation for Character Locomotion

Hi, I’m still relatively new to Unity and these forums, so allow me to introduce myself.

My name is Rune, and I am studying Multimedia with specialization in Game Programming at the University of Aarhus in Denmark. I have just begun working on my Master Thesis, which I will be making in collaboration with Unity Technologies.

The Master thesis will be about “Adaptive Animation for Character Locomotion”, which basically means creating a system for adapting walking, running, and crawling keyframed animations to a dynamic environment. The system will take curved paths, uneven terrain, and variable speed into account all the while ensuring graceful footsteps without slipping feet and motions that stay as faithful as possible to the original keyframed animations under the given restraints. Inverse kinematics is one of many techniques that will be involved in this.

The system is meant to be generic in nature, working not just for biped characters (with two legs) but also for example for dogs, bugs, and spiders and, say, robots and aliens, provided that they move around using a limited number of legs. This list of features is the ideal case - time will tell how far I get within the timeframe of my Master Thesis. Hopefully I can continue working on the project after my graduation, if necessary.

In the end, the result of my work will be made available to all users of Unity free of charge, for any use. If anyone are interested, I’d love to get people in this community involved in testing the system as it is developed, since one important success criteria is the usefulness and usability as perceived by the developers using the system. It will take some time before the first prototype is ready though, as I’ve only just begun.

In order to quickly get my feet wet, I’ve made this little demo, where I have modified the Goober guy that comes with one of the Unity tutorials, and made his legs use some very simple inverse kinematics:

http://runevision.com/multimedia/unity/ik/Goober%20IK.html

Note that in this simple demo I simply adjusted the altitudes of the feet, so feet slippage etc. are not prevented. The actual system will work in a completely different way.

I also have a question: The simple inverse kinematics I used here uses an analytical method that only works for limbs with three joints (hip - knee - ankle). For limbs with more joints this approach cannot be used, and an iterative solver of some kind have to be used. CCD and Jacobian Matrices are some examples. Have anybody implemented such IK solvers, and would be willing to share the code?

The actual inverse kinematics implementation is not a focus of my master thesis and not really one of my strengths, so I’d be happy to use an existing implementation if one exist. This would be fully credited in my master thesis of course.

Lastly, if anyone are curious about any of the prior work I have done, there are various game projects, 3D graphics and other things on my website at
http://runevision.com
Of interest might be the game Flipside, which was nominated for the Best Student Game award in the Independent Games Festival at GDC this month (though it didn’t win).

I’ve already seen how incredible helpful and resourceful this community is, so I’m looking forward to working on my Unity project over the next several months!

Rune

I think it’s already looking pretty damn good. Looking forward to seeing more.

You could use hinge joints for n joints IK and let the physics engine deal with it… and for body height and rotation, try a hover mechanic (search the forum for Yoggy’s buggy or the island’s Heron)
I’d like to see this applied to giants roaming hills…

The controls and general feel of Flipside are awesome! It’s nice how the character uses his hands to help him scale tight slopes ?

Very cool indeed.

It seems like if you actually had animations set up for your purposes you could use simple, brute-force approaches.

E.g. animate the figure once as “squatted” as possible, and once as “tip toe” as possible, and then interpolate to get the desired result. You could interpolate between poses to allow arm movement and hand targeting.

This approach wouldn’t require real-time solving… In fact you could build look-up tables to show the interpolation value best suited for a specific outcome.

You could use a similar approach to cope with slopes.

I might add that interpolating between well-designed animations will probably produce much better results than simply applying an IK solution (since IK solutions often produce pretty terrible results, which keeps competent cg animators fully employed).

Has this been done before for this purpose? I haven’t heard about this approach in any of the papers I have read. Also, it would seem to me to require much more ressources than a “simple” IK solver, that doesn’t have to take mass and forces into account. The system is supposed to be scalable to dozens of characters, so I want to avoid unnecasary overhead. Still, I’d be interested in hearing about previous implementations of this approach.

I’m not sure what you mean by hover mechanic, but I have seen the heron previously and didn’t see anything special. The body height will be determined by the heights of the feet, which again are determined partly by the characters collision object and partly by sending trace rays towards the ground. A simple version of this mechanic is already in the demo above.

Thanks! Was there a question there?

Thanks!

While this can work well in some cases, it require a vast amount of animations to interpolate between in order to get any real flexibility. We’re not only talking about walking uphill and downhill but also on sideways sloped surfaces, walking in curves, walking with various speeds etc.

Actually, in the papers I have read that does use interpolation of existing animation data, it is shown that the interpolations values are often non-linear and do require realtime solving. (Look-up tables is a possibility but could just as well be it for inverse kinematics.)
Because of the large amount of data involved, I don’t think many developers bother with a pure interpolation solution.
What I intend to make is a system that is very simple to setup and only requires a minimum of animations to interpolate between, which are then adapted, partly by using IK.

I don’t disagree with this, but as stated above the costs of low flexibility and large amounts of work often result in this approah not being very widespread OR only working in a limited set of environments.

Rune

I really don’t have much to contribute, but I must say I very much look forward to using this once finished! Even what you’ve done in your simple demo, I could put to good use :stuck_out_tongue:

I’ve got the book Physics-Based Animation, and it seems to have a very lengthy section on Kinematics

It may be worth giving a look at.

I’m glad to hear that! The current code is too much of a mess to share just yet, but I’ll try to quickly get to a point where it’s usable, even if just in a limited way.

I looked it up on the net, and although it seems to be more focused on how to code the tools than on how to apply them, I’m still going to check it out. Thanks for the tip.

Rune

I created the script for the heron walking in the island demo, and it does basically the same thing as what you did here.

I don’t think you should bother with any physics, that sounds like a nightmare to get working and smooth.

What I learned from my experiences with animation blending and IK (Mostly the robots in avert fate) is that it is best to get an approximation from blended animations and then do small adjustments with IK because the blended animations usually don’t mess up dramatically, but they aren’t accurate.

For example in avert fate I blend some animations and poses that effect different body parts to get an approximated animation frame for any running and aiming direction, then snap the gun to the aiming direction and snap the hands to the gun. Then I move the arm bones the same direction as I moved the hand, but less and less as it gets closer to the shoulders.

Good luck with your project! Sounds like something a lot of us could benefit from learning about :slight_smile:

I did see your heron script, but as far as I could tell, the bones there are translated rather than rotated, thus breaking the herons legs, as explained here (http://forum.unity3d.com/viewtopic.php?p=56770#56770). I got a screenshot of it too. This is not really inverse kinematics, but as long as the deformation is small enough, most people won’t notice of course.

I was really impressed by the Avert Fate demo. I’m curious how many aiming poses you interpolated between? Something like one for aiming left, one for right, one for up, and one for down?

Thanks, and I’m glad to hear that! :slight_smile:

Rune

Yeah, we had 5 or something poses I think, forward, up, down, left, right. There were some animation issues because the root bone was used in some animations and not others, so I had to go a bit of a roundabout way to get the aiming and walking working well. Watch out for that.

And yes I know I am breaking the herons legs but I am evil and don’t care, because no one will ever notice unless they read the code :wink:

Yeah, there seems to be some tricky issues.

One thing I have wondered is if there is any way in Unity to read arbritary bone animation data, such as “What is the transform of bone X at time Y in animation Z?” even though you are currently using a different animation and is at a different time in the animation playback.

Same goes for the reference pose. As far as I understand, all animated models have a reference pose, and it would be useful to be able to read the transforms of the bones in that pose at any given time. Is there any way to do that in Unity?

Rune