Hi, I’ve only spent a week using Unity so far so very new! Trying to make an arcade-style falling game within a tunnel. I can’t get this to work, despite having used this before successfully.
void OnTriggerEnter(Collider other)
{
print("YAY!");
if(other.gameObject.tag == "Finish" && finished == false){
if(terminal == true){
win_text.text = "YOU WIN!";
} else {
lose_text.text = "YOU LOSE...";
}
finished = true;
} else if (other.gameObject.tag == "Obstacle"){
// can add response to collision with obstacles.
}
}
To my disappointment, the phrase “YAY!” is never printed, and there is no interaction with the various GUIText elements.
As you can see, I tried fixing it by having the GUIText not constantly refresh (it finishes with constant contact) by adding an extra boolean, but it wasn’t even being run in the first place.
The player (sphere, Sphere Collider) has this script attached to it, and the finish (cube, Box Collider) has the tag “Finish”. The player has a Rigidbody, the finish doesn’t.
I’ve been stuck on this for hours now and looking at similar posts I can’t resolve the problem. Please help!