Hi So I’m new to Unity and I have this simple score set up where when the laser collides with an enemy it adds to the score but it is not increasing as it hits. Also since my laser is an object that appears the GUI of score shows up multiple times when a laser is fired. So i was wondering how i could fix this and why the score isn’t increasing.
Here is code on Laser:
private int Score = 0;
void AddScore () {
Score++;
}
public void OnGUI() {
GUI.Label(new Rect(20, 40, 100, 20), System.String.Format("Score: {0}", Score));
}
public void OnTriggerEnter(Collider collider) {
AddScore();
}
}