Enemy doesn't attack

Hi. I doobled check the code, I spent 3 days trying to find out what’s the problem, but succesless. When the enemy is attacking, it doesn’t damage the player. Nothing happens. I rewrited the code a lot of times, and it doesn’t help. So, probably you can help me? As far as I can see, the spelling is right.

Hi CJ89,

In which course and lecture are you? Have you already tried to add Debug.Logs to your code to see what is going on during runtime? For example, are you able to log a message into your console when the player is supposed to attack? Without knowing your code, it is impossible for me to interpret the messages. Maybe the enemy is attacking. Maybe it’s not.

I’m in the lecture 169 of the course zombie runner. I texted Debug.Log( you are dead) but nothing happens

Where did you put the Debug.Log? Could you please share your relevant code as formatted text?


See also:

Sure, here there is a link
attack
https://drive.google.com/file/d/19V1kzuk7gIZSpj-scj2INuOS05KFSIY8/view?usp=sharing

health
https://drive.google.com/file/d/1tUMI8Wo4vs9eO0kDaRf7YT1FYu3yDstr/view?usp=sharing

Thank you. How many PlayerHealth scripts are there in your scene? Maybe FindObjectOfType<PlayerHealth>(); found the wrong object.

There is one script

I’ve noticed there is no “target” in an inspector by enemy attack.

I solved the problem, but don’t know how lol. So, everything is working

Good job! :slight_smile:

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

Privacy & Terms