Realistic animated character movement 3D (locomotion)

Hello everyone! I’m a beginner in animation. This is my first post here, and I’ll try to express my thoughts, but they may be a bit chaotic, so I apologize in advance. I’ve looked through a lot of discussions but haven’t found a more or less detailed guide on the existing approaches to animation and how to use them. For over two weeks now, I’ve been trying to achieve realistic movement of a humanoid character using animation. If I’m mistaken about something, please correct me, as I’m just learning.

Studying the options on how to achieve this, I’ve realized that there are several main approaches to animation:

There are 2 main approaches to character movement:

  • The first one uses object movement through code/physics (transform/Rigidbody), and character movements are controlled through code, while animation plays independently of the movement and does not affect it.

  • The second approach uses animation for movement (root motion), and transitions between animations are used to make it walk, stand, or walk slowly. By adjusting the animation, we adjust the movement.

There’s also a mixed approach that switches between 1 and 2 depending on conditions.

The method of movement itself (root motion) can be further divided into 2 main categories:

  • The first is FK, i.e., animation based on ready-made animation clips (here I include Mecanim and other assets like MxM or Animacer).
  • The second approach is based on IK, where limbs are controlled directly through code and scripts (here I include Unity’s Rigging as well), and essentially we need to animate the character in code.

There’s also a hybrid approach, but as I understand it, it’s simply logic that switches between IK and FK at certain times.

Besides all this, there are different ways of movement: 8-directional or straight, but with torso rotation.

As an example of the result I want to achieve, I took a video from the Unity Addiction channel:

In my opinion, this is quite an impressive result, and I want to achieve at least something similar.

What I’ve achieved so far:

I’m using the root motion approach and would like to implement everything using Unity’s built-in animation system, Mecanim (despite all its drawbacks, I think it’s possible, though I could be wrong). I’ve also studied John Mac’s series of tutorials on creating an animation controller (I think it’s a pretty powerful starting point). In the series, he uses the root motion approach without using custom IK. (For now, let’s simplify the directions of movement and leave only forward movement.)

And finally, we come to my problem, based on the fact that I can’t seem to eliminate foot sliding at the start and end of walking (these are my personal improvements).

The main problem:

(At the start of walking) The problem is that the position of the feet when transitioning from one animation to another may not match the position of the feet in the second animation. And when transitioning from idle to walk, instead of the left foot staying in place and the right one moving forward, the right foot moves forward, while the left one moves backward, making it look like we’re walking on ice.
(There’s also a problem that we can start with either the left or right foot, but for now, I’m not considering this issue (let’s assume we always start with the left foot).)

To solve this problem, it was decided to find additional “start walk” animations where the foot is on the ground, and the transition looks like this: idle → start walk → walk, and it already looks good. (But here, too, there are problems, which we’ll talk about later.)

(At the end of walking) Here it’s a bit more complicated: if when transitioning from idle to walk we could choose to start with either the left or right foot (and we chose only one option), then here we have the concept of “step phase” (correct me if there’s a more correct term). We can have at least 4 foot positions (left forward, left supporting / left forward, right supporting / right forward, left supporting / right forward, right supporting), and there’s also a step length parameter that further complicates things.

And so, we need to write a system that will analyze the position of the feet and, depending on these parameters, choose one of several transitions.

But even after writing such a system, I still can’t achieve an acceptable result; incorrect transitions still occur somewhere and sometime. The question is as follows:

  • Can someone correct my logic/theory I’ve outlined so that people who are also just starting their path in animation would have some guidance or materials?
  • Most likely, I won’t be able to achieve a fully acceptable result using only the animation approach, or will I (I don’t know)? And I don’t want to use purely IK, as I want to leave the option to change animation clips for walking. So, do I need to use a combination of animation and IK, or can it still be done through animation? What do you think about this?

Thanks in advance for your response.

are you using three states and two transitions for idle → walk → run ?

you may try using a single state blend tree for the idle/move/run animations
as it probably would be controlled by speed parameter. their root motion may be better match up with the distance it travels.

if that still unsatisfactory, although there is animation match target to use, one animator only can have one match target at any time. not good to use up for walk/run cycles. ik feels a better fit for placing feets

There are many more states in the animator than (idle walk run). I removed the excess to better show the gap. The mixing tree also doesn’t give the desired result, because if you mix idle and walking animations, you’ll end up walking in small steps (it’ll be less noticeable, but the problem will still be there). If you run this animation immediately after the idle animation, the left and right legs will still be simultaneously interpolated into the correct position in the new animation (it will still look like the legs are moving apart). I have already reviewed many implementations but have not found anyone who would deal with this problem. except for the reference video

how can I combine the play animation approach and the ik leg installation approach?

  1. find the normalized time or use animation event at the moment where the animation will touch a foot onto ground, record its world position. (may use raycast for the actual placement as well)
  2. use the ik position and full weight to fix the feet
  3. find the time or use animation event at the moment where this foot will leave the ground, gradually reduce its ik weight

you can calculate foot positions (which will be approximate*)
*unless you do sg like sampling and analyzing all animations beforehand

and if you know which foot your next animation starts, you can crossfade to when the foot is in that right position

here’s the display of foot positions in Renegade in the right bottom corner
9842799--1416321--RenegadeFeet.gif

it uses blend trees w multiple animations, and in that case normalized times of foot ground touch shifts
(so anim event approach only can be used if states have only one animation)

interesting idea. I tried using IK during animation. For the test, I set the position and weight of the IK for 1 leg and it worked. however, several new problems arise for which I am currently testing and looking for a solution: 1. we need to come up with a system by which we will know when we need to apply weight mechanics.
2. you need to apply IK in such a way that the leg does not move from its place however, when the corresponding part of the animation is played, the heel can be lifted off the floor for greater realism

To track the position of the legs, I currently see the following options (but I still haven’t tried them):

  1. using events in animation
  2. using curves in animation
  3. get a link to each leg and use the code to track which of the 2 legs is in front and which one is now stable

So I tried to make such an animation without using the ik system. the idea was to take into account the current position of the legs (for example, through the distance between them and which of them is stable and which is leading) and, depending on this, include a transition in the animation. However, this mechanim does not support changing animation transition parameters from code. I came up with 2 ideas: 1. Therefore, here you will need to configure 5-7 transitions with different parameters only between 2 animations (I did exactly this approach, here is the result), which very painful.
2. There was also an idea to make a tree of rotations using animations, where using parameters we selected the transition to 1 of 4 animations. However, it didn’t work out here either, since you still need to take into account the current position of the legs and the speed and length of the shift so that it looks normal, without twitching. (This can be done in theory, but the number of similar stop clips will be very large)

For now, the closest I’ve found is this post and its free implementation in a asset store.
As far as I understand, his idea is to use animations and analyze them to turn on the IK when the foot touches the ground. This way, the animation from the video is simultaneously preserved and the problem of feet slipping is solved.
I like this idea, but it has a problem: the implementation doesn’t have any mechanics to account for heel lift off the ground and toe curl. which seems to create the effect of sticking to the ground.
I’m currently learning this code and how it works with animation clips

I didn’t find anything similar (even from paid resources). maybe you can recommend something