I want to hit the enemy 3 times to destroy ~ I changed the code that does not work Can ask the experts tell me why?
function OnTriggerEnter(hit:ControllerColliderHit) {
if(hit.gameObject.tage("enemy")) { if(hit == true*3) Destroy(gameObject); } }
I change my scrpit. I want to hit the enemy 3 times to destroy.
private var hitCount = 0;
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject.CompareTag ("enemy"))
{
hitCount +=1;
}
if(hitCount == 3)
{
Destroy(gameObject);
}
}