My scoring system is not working as planned, and here is what is what is suppose to happen, and what is happening.
-
Score should not populate when player hits an obstacle, but it still hits trigger and populates score when player hits an obstacle and does not correctly avoid the obstacle.
-
Score should only multiply when player correctly avoids 3 obstacles, but it is multiplying every time we score.
Here is what i have so far, any help would be greatly appreciated.
public class Score_System : MonoBehaviour {
public static int playerScore = 0;
public int pScore = 10;
private GameObject scoreText;
public int combo = 0;
void Start () {
scoreText = GameObject.Find("scoreNumber");
}
void Update()
{
if (combo >= 3)
{
pScore = 20; //the increased points
} else {
pScore = 10;
}
}
void OnTriggerEnter(Collider other)
{
if (gameObject.CompareTag ("Pickup")) {
gameObject.SetActive (false);
combo += 2;
playerScore += pScore * combo;
Debug.Log ("Points triggered");
}
if (gameObject.CompareTag ("obstacle"))
combo = 0; //Resets the combo, but upon next pickup will gain +1 from the Pickup collider
Debug.Log ("Combo reset");
}
void OnGUI()
{
scoreText.guiText.text = playerScore.ToString();
}
}