OnTriggerEnter and -Exit not getting called
I'm trying to make text appear if the player is inside a trigger and presses 't', but OnTriggerEnter doesn't get called when I enter the trigger. I've double checked the layers, tags, if the player has a rigidbody and if the collider is set to trigger but I can't find the problem. I'm at my wits' end.
Also, my game is in 2D in case that makes any difference.
public int conStage = 1;
public bool trigger;
void OnTriggerEnter (Collider other){
if (other.gameObject.tag == "Player") {
trigger = true;
}
}
void OnTriggerExit (Collider other){
if (other.gameObject.tag == "Player") {
trigger = false;
}
}
void Update (){
if (Input.GetKeyDown (KeyCode.T) && trigger == true) {
conStage = conStage + 1;
}
}
}
Answer by uzifuz · Nov 11, 2015 at 05:49 PM
Nevermind, I figured it out. I just had to add 2D at the end.
void OnTriggerEnter2D (Collider2D other){
void OnTriggerExit2D (Collider2D other){
Your answer
Follow this Question
Related Questions
About the door animation trigger 0 Answers
How do I destroy an instantiated game object when player leaves trigger area? 1 Answer
Safe Zone when in trigger zone? 0 Answers
OnTriggerEnter2D() does not work !!! 0 Answers
My OnTriggerEnter2D Won't work. 1 Answer