Matching walk/run animation with character movement

Started by
11 comments, last by comfy chair 10 years, 7 months ago

Hi,

I need to implement accurate footfall animations for my human characters. The goal is to have a realistic animation play whatever direction the character is moving, and whatever speed (below some maximum). The character's feet must never slide across the ground.
Ideally, he should be able to sidestep and walk backwards too.

My animator has provided me with different gait anims - walk, jog, run etc. They need to blend into each other as appropriate when the character accelerates.

Can anyone point me to articles/keywords that I can use in order to design and code this?

By the way, I'm coding in XNA and using the Animation Component library.

Advertisement


The goal is to have a realistic animation play whatever direction the character is moving, and whatever speed (below some maximum). The character's feet must never slide across the ground.
Ideally, he should be able to sidestep and walk backwards too.

if you move the model, and the animation just manipulates the mesh, then its up to you and your artist to sync the animation speed and the movement rate. IK may help here. or you can just do the math. the animations moves x frames per stride, where a stride is y meters. the character moves at z meters per second. solve for x.


My animator has provided me with different gait anims - walk, jog, run etc. They need to blend into each other as appropriate when the character accelerates.

when the time comes to switch from jogging to run, you tween from the current jog frame to the first run frame. then loop the run animation. this is one form of animation blending. blending from one animation to the next. the other form is individual animations for different parts of the model, IE run combined with swing sword, for example.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Hi, take a look at this GDC presentation: http://www.gdcvault.com/play/1012300/Animation-and-Player-Control-in

I don't remember where I read this, but in order to have a run animation blend properly with a walk animation, they both need to be proportinally synchronized. This means, if one of the character's foot is touching the floor at 50% time in the running sequence, that same foot also needs to touch the floor at 50% time on the walking sequence.

This is regardless of these sequences' length.

You could allow the animation to move the character using a unique bone. This way, foot slip can be avoided by the animator's doing. However, this also means that in-place walking or running loops wouldn't work for the idea I'm describing.

The bone can be whatever makes sense for your game (Hip, waist,or root bone). Since the unique bone affects the position of the player, it would make sense to actually animate it. In the animation engine, just move the actual player based on the change in position of the unique bone from the last frame. Or when an animation ends, loops, or is interrupted (the player got hit), add the unique bone's local animation position to the actual player's location.

I know you're making a football game, but let's just say you're making a platformer. There's alot of jumping and whatnot. After reading what I said above, you might be tempted to have a unique bone control the jump height. But that could lead to a problem if you want the jump height to be a bit dynamic and depend on how long the "A" button was pressed. What you might actually want to do is just animate the jump in place. Then in the game, add in whatever jumping physics you want to change the position.

Anyways, this allows your animator to have better control not only over foot-slip, but the speed and movement dynamics of players. A slow runner would only run slow because of his animation.

if you move the model, and the animation just manipulates the mesh, then its up to you and your artist to sync the animation speed and the movement rate. IK may help here. or you can just do the math. the animations moves x frames per stride, where a stride is y meters. the character moves at z meters per second. solve for x.

OK. So I simply adjust the animation speed every frame according to those numbers. That sounds sensible.

when the time comes to switch from jogging to run, you tween from the current jog frame to the first run frame.

Hmm... so if I just blend for half a second or so into the first run frame, it will look seamless? No floating or jerking about?
I would have thought that the source frame would also be important - so for instance only blending between frames where the legs were in similar poses. So the jog frame that had the left leg on the ground would need to blend into the run frame where the left leg was also on the ground.

What you are looking for is called Motion Extraction, or sometimes also called Root Motion.

Sometimes it is also referred to Variable Motion Extraction, because the motion is not constant, but defined by some node inside the motion itself.

What you basically do is take a given root node, for example the Hip node, and extract the translation and rotation delta from that for the given frame.

Then you filter that transform, to for example only rotate around the up axis, and capture only movement on the ground plane.

Then instead of applying this transformation to the hip node, you apply it to your actor itself.

Your motion is now driving the position and rotation of your character.

When you blend two animations together, for example if you blend between a walk and run motion, you should calculate the delta movement from each motion, and blend these two delta transforms by the same weight as you blend your motions.

This is the basic idea. There are several things you have to take into account, such as looping and scaling of your character.

Your animations will not be in-place animations anymore, but they have to move away from the origin (in case of moving forward or so).


I don't remember where I read this, but in order to have a run animation blend properly with a walk animation, they both need to be proportinally synchronized. This means, if one of the character's foot is touching the floor at 50% time in the running sequence, that same foot also needs to touch the floor at 50% time on the walking sequence.
This is regardless of these sequences' length.

this is what i call the "neutral frame", "matching frame", or "common frame" method. two animations have a keyframe that "matches" - left foot on ground, for example. and that's the point at which you can switch from one to the next cleanly. using this you can avoid tweening. by having short animations with matching frames, such as the first frame, you can simply sequence animations witthout blending. and its actually a bit more realistic. in real life you drop from run to walk as you forward foot hits the ground, which would be the "matching frame", probably at the beginning of both animations. in real life you don't tween from a run stride to a walk stride in mid-air. if you did, you'd probably break you ankle when you landed! <g>.

yet another technique is to use short "transition" animations. IE something that plays just once for a few frames, at the end of a run loop, and before starting a walk loop, for example. or simply tweens from the current frame to the next "common frame", then switches to the new animation.

i personally try to find a "common frame" pose i can use for all animations, then simply use that as my transition point. also, as i recall, my animation engine automatically tweens from current frame to new frame if required when switching ani's.

due to the necessity of modeling player physics realistically (unless its Mario football <g>), you'll probably want to keep the animations separate from, yet driven by, the physics simulation, IE use in-place ani's, and control stuff with code.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

To be honest, using the method of the poster above does not really make nice transitions between walk/run/jog. It might work nice for other cases, but not for locomotion.

You do want to blend here and not just switch instantly between the animations, as that suddenly makes the character go a bit faster, looking unnatural.

What you want are real smooth "analogue" transitions, where you can move the analogue stick slowly up, where it goes faster and faster, without any sort of popping and where the speed of the character goes faster and faster.

It looks way nicer to smoothly increase speed from a walk into jog into run into sprint instead of just switching between them at given speed values.

You need to do some full clip or foot plant synchronization there and use the motion extraction I mentioned before, to get the best results.

You need to have the animation keyframes mathematically matched between the animations. In other words you need functions for finding the relevant keyframe in run animation to current walk animation frame.

It's all about finding the same key points in each animation and getting down their locations. For example Left foot touches the ground at frame 25 of 100 in run animation and frame 50 of 200 in walk animation. Divide relevant keyframes by animation duration and you get the percentages you can compare and match between animations. Hopefully the animations were made so that the key points are in same order starting point wise because that makes you job easier. If not, then you need to add/substract an offset like 0.3 to the percentage accordingly.

Blending from a "Walk animation" to "Run animation" requires some additional consideration than a standard blending because the foot keyframe need to match.

There are a lot of info from the previous post, I can let you a method.

We will assume each animation will loop and contains one full gait cycle.

We will assume the walk duration is dwalk and duration of run is drun.

We will assume the velocity of walk is vwalk and the velocity of run is vrun.

What we want is blending in phase, so we need an offset for each animation who is when the left goot hits the ground.

We will assume these offset are owalk and orun.

We will assume f is our dissolve factor [0...1].

We can compute the final velocity :


final_velocity = Lerp(vwalk, vrun, f)

To make the blending in phase we need to adjust the speed of each animation.

This means the walk animation need to speed up and the run animation need to slow down.

We will assume the current time of walk animation is twalk.

We can compute the run animation time :


trun = mod((twalk - owalk + dwalk) * (drun/dwalk) + orun, drun)

Now, we can speed up the walk animation appropriately :


speed_walk = Lerp(1.0, (dwalk/drun), f)

You should have all info you need to know to have a correct walk to run blending.

This topic is closed to new replies.

Advertisement