Character Controller Is Lagging Behind Enemy

I’m working on a game with some basic zombie AI and everything seems to be working except for the fact that the character controller seems to be lagging behind the enemy as he moves which makes him sort of jump backwards every so often to correct himself and I’m not sure how to fix it. This also causes the enemy to seem to grow in my First Person camera view but not the other scene camera.

Here is a short video I recorded so you can better understand what I am talking about:

If you’d like to see the zombie AI code it can be viewed here and the other code would be straight from the Unity FPS tutorial pretty much.

Thanks for your help, I really appreciate it!

2 Answers

2

Looks like he has forward translation keyframes on his skeleton root during the walking-forward animation. Every time the animation loops, he pops back to the original local position.

Find your character in the Hierarchy, and look through its child objects. There should be something called “Root” or a similar name for the top-level joint in the skeleton hierarchy. I haven’t worked with Mixamo animations so I don’t know their naming convention.

Select the root joint and then open the Animation View (Ctrl-6). In the top left corner just under the record and play buttons, you’ll see two pull-down menus where you can select the different animations applied to that character. You’ll need to dig through this and find the walking-forward animation. Once you have it selected, look for “Transform”, click the triangle next to it if it isn’t expanded already, and select Position.x, Position.y, and Position.z.

Press the F key to center the animation data in the graph to the right. You should see one animation curve gradually increasing (or decreasing) in value, and doesn’t return to its original value at the last frame. It will probably be Position.z. Select all the keyframes in that animation curve except for the very first one, and delete them. That should stop the character from animating itself off of your character controller.

(If you don’t see an animation curve for the root joint that fits the criteria, it may mean there’s another joint in the skeleton under the root that’s translating forward- Perhaps a joint called “pelvis” or “hips.”)

Here’s the Animation View reference:
http://unity3d.com/support/documentation/Components/animeditor-UsingAnimationEditor.html

Hope this helps!

this comment greatly clarifies your question. I'd say you Do know the input range: it's the min/max of the data values. With that in hand, @BastianUrbach 's answer has all you need.