I’ve written a script that deducts lives every time that my object collides with a ball, however, the object does not get destroyed when it reaches 0 but, instead, has to be hit one more time at zero to be destroyed. I would like the object to be destroyed when the lives reach 0 and not have to be hit one more time. Here is my script:
using UnityEngine;
using System.Collections;
public class RedBase : MonoBehaviour {
void OnCollisionEnter (Collision col) {
RedLives();
}
public void RedLives() {
if(Lives.redCurLives > 0)
Lives.redCurLives--;
else {
GameOver();
}
}
public void GameOver() {
Destroy(gameObject) ;
}
}