- Home /
Hit enemy life
this is the part of the bullet code that take enemy life:
rayAim = Camera.mainCamera.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2, 0));
if(Physics.Raycast(rayAim, out hit, range)) {
Zombie enemy = hit.collider.GetComponent<Zombie>();
if(enemy != null)
{
enemy.health--;
}
}
on Zombie script I have the variable : public float health;
i'm about one day finding what's wrong there, the gun instantiates the bullet in the currect direction, and the enemy has a collider
i don't receive any errors
using Csharp
someone can help me?
Comment
Your answer
Follow this Question
Related Questions
Shoot Bullet Delay Enemy 0 Answers
No collision on trigger and character controller 1 Answer
Problem with enemy shooting 4 Answers
Enemy Instantiating one bullet 3 Answers
Bullet Shoot At Enemy Position 1 Answer