- Home /
Activate Object with trigger and if leave then inactivate
I have a Box Collider and I marked it 'Is Trigger' . If Player enter BoxCollider, then Object activate, and if Player leave the BoxCollider then this Object is inactivate. What is the javascript for BoxCollider?
Hmm, I'm not sure what you're looking for, but maybe this is useful:
http://docs.unity3d.com/Documentation/ScriptReference/BoxCollider.html
Answer by zero84085 · Jul 18, 2012 at 07:43 AM
Hi my friend and forgive me for spelling errors first you need to khow 3 functions OnTriggerEnter OnTriggerExit OnTriggerStay and what is a boolean
here is a example var Cube : boolean = false;
function OnTriggerEnter(){
Cube = true;
}
function OnTriggerExit(){
Cube = false;
}
what is this script?
first we have a boolean that is true or false if is true do some action and if is false that does other thing so if the player enter the trigger the Cube going true (active) else if exit the Cube go false; (inactive) i hope to understand how works!
Thank You John Stavrakakis! :) It's very usefull for me! I have no permission to do Vote Up...I dont know why. Sorry about that!
Very good explanation! I just wondering its possible to provide example for C#? Sorry i am new to Unity 3D
thanks
Answer by Piflik · Jul 13, 2012 at 07:18 PM
All you need are the OnTriggerEnter and OnTriggerExit functions. Use these to toggle a boolean variable.
Your answer
Follow this Question
Related Questions
Activate a Object 1 Answer
Trigger help! 0 Answers
Triggers? How do I use them to finish a game? 1 Answer
Jumpscare (Triggers and stuff) 1 Answer
C# Make two objects collide to activate a third object 3 Answers