Animator Woes

Read Time:3 Minute, 48 Second

Ok, so I work through a lot of important issues during this post and I come up with an imperfect solution that I am going to leave aside for now because I want to continue my journey in other ways. The video below is the working solution I am moving forward with at this time. If you are interested in the journey that got me here, read on past the video.

Here are the relevant changes to the Zombie Animator script. Essentially Update Position toggles have been commented out and we let the Agent do its thing with one exception: in the callback On Animator Move, the speed of the Agent is computed using the Animator. This has the effect of producing the correct speed but not the correct look. It is good enough for now.

Root Motion is turned off and the Agent is left to its own machinations.

Well that’s not right…

I turned on Shadows and added a Hit animation and now I know how bad things really are. Here is a non-exhaustive list:

  1. The Zombies do not touch the ground with Nav Mesh Agent positioning turned off.
  2. The Idle state does not touch the ground even with it turned on.
  3. The Hit animation pushes the Zombies off the ground.
  4. When dead, the Zombies still rotate to face the player.
  5. Turning Physics on doesn’t help.

And a potential solution:

https://www.meshtint.com/blogs/tutorials/tutorial-how-to-fix-floating-feet-when-using-mecanim-to-share-humanoid-animations-in-unity

What is root motion and how does it work?

I got rid of a capsule object that required everything to have a weird offset. Nav Mesh Agent was at 1. It can be zero with the Synty Mesh because the the character transforms are at the feet. This means the transform of the Zombie can be zero instead of -1. This doesn’t do much for the feet floating off the ground just yet, but it’s a start.

The next task will be to get the Zombie’s feet on the ground.

Gotta do something about the floaters.

I found the article on How to Fix Floating Feet on the Mesh Tint website. It essentially comes down to understanding what you should Bake Into Pose and what you should let the Root Motion deal with. This article has what seems to be a popular answer on that subject.

Baking the root transform into the pose prevents that part of the transform from affecting Root Motion.

If you don’t want the Transform to turn, check rotation.

If you want the Transform to stay on the ground, check Position (Y).

If you don’t want the transform to move about on the ground, check Position (XZ).

We want our Zombie’s feet firmly on the ground. So we want to check the Position (Y) box.

Yes to Bake. Switch to Feet.

The final adjustment is to apply Foot IK to the State in the Controller.

This needs to be done for all the animations.

And here’s a test of the improvements on the Idle animation for one of the Zombies.

Some small success here.

I made some more adjustments on the fly for the Movement, Death and Hit animations which I detail in this video. I also notice a huge flaw in the plan.

Is this the end of the Root Motion experiment?
Can I get these guys to climb stairs?
We shall see.

Can I summarize in a nutshell what I learned?

  1. Freezing the Position (Y) is critical for the various animations.
  2. Foot IK is window dressing.
  3. Stair wells are a bitch.

The best way to start the Zombies off on the Nav Mesh is to have the agent updating the position at the start of the game. The following are changes to the Zombie Animator component. Whenever we need to use Root Motion, we disable the Nav Mesh agent and let em go!

Toggling Update Position of the Agent on and off.

This bit of code is begging (BEGGING) for a state machine. I resist! This is throw away code and I am already deep down a rabbit hole.


It’s worth noting that removing the Capsule Collider and adding a mesh collider onto the Mesh means that the Collider is now on a child game object. We need to cast up to the parent in order to find the Target now.

Similar changes need to be made to the Impact Handler as well.


Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleppy
Sleppy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *