Triggering animation and attack state from our code

I am just on the part of the course where you set the animation from Idle - Move - Attack and well as I followed the Video instructions on some point the enemy just stoppen moving, now I got it back to move as I just did what was said in another Thread but now the enemy will not attack.

I will share the link to the thread so you can see what I am talking about.

Thank you in advance!

Here is the link:



In which course and lecture are you?

Complete C# Unity Game Developer 3D

I am lecture 6 Zombie Runner - First Person Shooter, It is Video number 167

Are there any error messages in your console when you expect the enemies to attack? Have you already tried to add Debug.Logs to your code to see what is going on during runtime? For example, you could try to figure out if the relevant code blocks are getting executed.

There are no error messages. I think it have to do with the animator or something that was changed in the lecture. The enemy is not chasing me and when I enable Enabling Apply Root, like the one in the other post said, then the enemy is following me again but the enemy stays in the state and is not switching to the attack state in the animator window. So he is not attacking.

Did you try to add Debug.Logs? In Unity and programming, there is no such thing as “enemy” or “chasing”. There is just code. For this reason, try to figure out first, if the relevant code gets executed as expected. Maybe the condition for “chasing” is always false. If it’s not and if the enemy “chases” the player according to what is being executed at runtime, check if the bool/trigger name is spelt correctly in your code. In the animator, there are bools/triggers defined. Those are the bools/triggers we want to control via code.

1 Like

How are you getting on with this, @SweetMouse85?

1 Like

I got it working! Thank you :slight_smile: Sorry for my late reply!

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

Privacy & Terms