How to I make individual hit boxes for my zombies?

#pragma strict

var health : int;
var Zombie : GameObject;

function Start () 
{
	Zombie = GameObject.FindWithTag("Zombie");
	health = 100;
}

	function OnTriggerEnter(other : Collider)
	{
		if(other.tag == "shot")
		{
			health = health - 34;
		}
	}

function Update () 
{
	if(health <= 0)
	{
		print("Enemy Down!!");
		health = 0;
		Destroy(Zombie);
	}

}

It works for my first zombie but not for the rest why is this?

–

1 Answer

1

Your code smells OK from here. I think the problem is somewhere else. Wild shot in the dark, perhaps you’re using an instantiate on a prefab that isn’t the same as the zombie you’re testing your first shot on.

I am not sure I know where that might be. I looked through all of my code. I usually don't find things with tag. I usually just drag the prfab into it.

–