Zombie Animation Bug

Hello, I come from the Blender course and there is a problem that I have had for long in my horror game and I thought that somebody could help me here. My zombie (enemy AI) teleports to its initial animation start location while still moving towards me. I have tried “once” and “loop” and “default” but the same thing happens anyway.

Here is a video of what it looks like:

Here is a screenshot of my “Animation” tab:

Here is a screenshot of the script that I am using:

I hope that my post is not completely off topic and I will remove it if somebody finds a solution or if requested.


No need to remove your post, your question is fine and will invariably help others too.

I’ve updated your topic though so that the video and images are actually included in your post rather than just links, sometimes this can be a bit of a turn-off for people who would otherwise offer help. Incidentally, you can just copy and paste your code into your posts and apply code formatting, this makes it a lot easier for those that want to help you as they can often just copy and paste a chunk of your code back for you with an adjustment etc, see the link below.

Regarding the issue, it looks as if the animation includes a degree of movement, almost as if the model is moved with the animation but then snaps back to where its transform was supposed to be. You could try taking a look at your Animator view and see if there is any changing of state which might shed light on to the problem.

As a debug step, I would probably look at lines 25 and 26, commenting out first the call to play the animation and see if the model does move as you would intend, albeit not animated. Then I’d probably switch that around, and just play the animation without the movement and see what happens.

I would be happy to have a look in more detail but would need you to share the project files in order for me to have a closer look. The forum will allow uploads of upload 10mb, so if you project files are larger than that you would need to use a service like Google Drive or Dropbox and then share the link in your reply.

See also;

1 Like


Thanks for taking your time to look into my post. It means a lot to me.

I tried changing the script based on what you have written and I did not manage to get the result that I was looking for. I also do not completely know how the Animator works, as I have only used Animation so far.

Consequently, I have decided to share my project files using mediafire.com. Here is the link: http://www.mediafire.com/file/o1wyyrdqvr5f6mb/Horror_Survival.rar/file

1 Like

Hi Vlad,

I’ll grab your project files now and take a look this morning, I have a couple of other tasks to complete but will do my best to respond today with anything I spot that may help :slight_smile:

Updated Fri Aug 17 2018 10:39

Hey @vcvlad,

I ran the game and moved to a position where the zombie would move towards me. I paused the game and switched to Scene View.

Selecting the ZombieEnemy GameObject and this illustrates what is happening very well. The animation plays and moves the Zombie GameObject, but the ZombieEnemy GameObject looks like it is being left behind, once the animation completes the Zombie GameObject snaps back to its transform position.

Here’s a little video where I step through the frames to show the issue in more detail;

I note that there isn’t an Animator in use here to manage the different animation states, I’m assuming you are handling this in code yourself instead.

I created a new scene, very basic, dragged the Zombie prefab in and gave it a parent GameObject to reflect your hierarchy. I then added an Animator to the parent GameObject, created a separate AnimatorController with just one state, walking;


I tried adding your Walk animation but it doesn’t appear to have motion, so I just added the walk motion from the Standard Assets instead.


When I run the game, the model animates on the spot. If we then enable the Apply Root Motion the GameObject will move in the direction it is heading, which can be manipulated, as I try to demonstrate in the last few seconds of this video.

At this stage, I’m not certain what is different about the walk animation you have for this model, over that of the standard assets one, but I wanted to reply now with some findings.

My feeling is that you may be better off using the Animator to create different states for your Zombie, e.g. its idle or its walking, these can be triggered from script, the root motion would allow you to have the zombie move towards the player as you could just set the rotation to look at the player etc.

I think your issue is one of synchronicity. You are animating the model, which has some forward movement of the model, this is running at one speed, and then you have the actual GameObject being moved separately, seemingly at a different speed. Increasing the speed on the GameObject just makes the issue happen fast, as the animated model is then just pushed along.

Updated Fri Aug 17 2018 13:38

Ok, so I’ve been fiddling with the actual animation. It isn’t possible to add the transform of the zombie to the animation and add to its Z position, effecitvely trying to make it catch up to the location of the model, because if you do, the enitre animation moves with it as it is a child of that GameObject. So, instead, what I did was removed the Z position keys for the Bip01 Position property;

What this does is prevents movement of the model on the Z plane. What happens now is this;

Sorry for the delay coming back to you, I’ve spent a couple of hours on this trying to see the best way to resolve the issue. The above works, but obviously I don’t know whether this was something that was included with the animation of your model, or if it was something you added yourself, possibly by accident etc.

I would still lean towards using the Animator for managing the state of your animation, but if you do go down this road, consider testing it all in either a separate project or a new scene with duplicated prefabs so that you can still return to your main project if things don’t work out.

Hope the above helps. :slight_smile:

1 Like

Wow, it worked. I cannot believe that you really put so much effort into trying to solve this. I am absolutely grateful!

1 Like

You’re very welcome Vlad :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms