So i have a trigger attached to my prefabs for the player to score when they jump over , or go under the obstacle correctly. But, there is 2 problems i am running into.
-
Player still scores when they collide with the obstacle, when it shouldn’t add to the score.
-
It is suppose to multiply score after a few completed obstacles in a row, but is not working.
Any help would be appreciated, i am probably over looking something simple.
public class obstaclePointTrigger : MonoBehaviour {
private mainRoot pMainRoot = null;
private gameRoot pGameRoot = null;
public static int playerScore = 0;
public int pScore = 10;
public int combo = 3;
public int multiplier = 2;
private void Start () {
findObjects();
}
//
private void findObjects(){
pMainRoot = GameObject.Find ("mainRoot").GetComponent<mainRoot> ();
pGameRoot = GameObject.Find ("gameRoot").GetComponent<gameRoot> ();
}
//
private void OnTriggerEnter (Collider other) {
if (combo >= 3) {
multiplier = 2; //the increased points
} else {
multiplier = 1;
}
//
if (gameObject.CompareTag ("Pickup")) {
gameObject.SetActive (false);
pGameRoot.changeScore(pScore);
//Debug.Log ("Points triggered");
}
if (gameObject.CompareTag ("obstacle")) {
//pGameRoot.changeScore(pScore * -1);
}
}
}