I have been fiddling around with the obstacle Course from the lecture a little bit and have added a live counter instead of a score. Now I sometimes run into the issue that my player collides with an obstacle, the obstacle changes colour like it should thru the ObjectHit script but my life counter does not decrease. This seems to only be happening with Objects that have a rigid body like the falling blocks or rolling balls. Does anyone have an Idea what might be the issue?
This is my Scorer script:
public class Scorer : MonoBehaviour {
public int lifes = 3;
public GameObject Button;
private void OnCollisionEnter(Collision collision) {
if (collision.gameObject.CompareTag("Collider")) {
lifes--;
if (lifes == 0) {
GetComponent<Mover>().enabled = false;
Button.SetActive(true);
}
}
}
}