• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
comfy chair

Matching walk/run animation with character movement

12 posts in this topic

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.

Edited by comfy chair
0

Share this post


Link to post
Share on other sites


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.

1

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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. 

0

Share this post


Link to post
Share on other sites

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.
0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites


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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

Edited by ShadowFlar3
0

Share this post


Link to post
Share on other sites

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.

Edited by Alundra
2

Share this post


Link to post
Share on other sites

I have a follow-up question - which is best:

Playing bracket animations discreetly (either walk, jog or run), or blending them together?

With blending, for a speed half between walk and jog, I would use weighted interpolation from the walk and jog animations to determine the bone transformations.

0

Share this post


Link to post
Share on other sites


Playing bracket animations discreetly (either walk, jog or run), or blending them together?

 

 

 


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.

 

Like Buckshag says, true "variable speed" animations are the best. whether achieved by blending bracketed animations or by some continuous variable speed animation system.

0

Share this post


Link to post
Share on other sites

Thanks. I am well on my way to have a smooth gait transition/footfall system for my characters.

(by the way, I am making a sim game, not a footballer).

0

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
Sign in to follow this  
Followers 0