- Home /
Text not changing once I've entered a trigger collider
The text isn't changing when I enter a Collider Im new to unity so I don't know why this isn't working.
public class InSecurityEvent : MonoBehaviour { public bool EnteredTrigger; public GameObject CollisionWith;
public Text ToDo;
public void OnTriggerEnter(Collider other)
{
if (other.tag == "SecurityCollider")
{
EnteredTrigger = true;
CollisionWith = other.gameObject;
ToDo.text = "Go to the monitor and press E.";
}
}
}
Did you check whether the OnTriggerEnter function actually gets called (e.g. with a Debug.Line())? It might simply not get called, if you don't set it up right. This might be the case if you interchange Collider and Trigger
Answer by Duckocide · Oct 26, 2020 at 09:18 AM
Have you ticked the "is trigger" option on the collider?

Your answer
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
Trigger Respawn 3 Answers
solution with on trigger destroy 0 Answers
Restraining movement to camera bounds 1 Answer
Shuttle Runs & Counter 0 Answers