- Home /
Pause game OnTriggerEnter
My idea is when an object " collide " with the " cubo2 " to pause the game , my script works but when the object goes out of this " cubo2 " the game is still not , someone help me ?
var paused : boolean = false;
// Destroy everything that enters the trigger function OnCollisionEnter (other : Collision) { if(other.gameObject.tag == "cubo2"); if(!paused){ Time.timeScale = 0; paused=true; }else{ Time.timeScale = 1; paused=false; }
}
Answer by supernat · Dec 30, 2014 at 09:33 PM
Use OnCollisionExit to handle the case of an object exiting the cube. OnCollisionEnter will only be called when the object enters the cube.
Your answer
Follow this Question
Related Questions
All the objects in my script choose the same target. 2 Answers
Access a child from the parent or other gameObject. 2 Answers
How do I make Destroy(gameObject) work in my script? 1 Answer
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Can you change a variable based on the tag of an object? 1 Answer