- Home /
Simple trigger question
I have a quiz type game in which you walk up to a door, get asked a question, and if you get the question right the door gets destroyed and you move on. If not it locks and you have to find a way around. Currently everything works fine with the exception then when your picking your answer the mouselook is spinning your character around. I've gotten it so I disable the mouseLook script on entering the trigger but if the person gets the question right and the wall gets destroyed, onTriggerExit never gets called to turn the mouseLook script back on. Any ideas?
Answer by BinaryCaveman · Aug 31, 2010 at 06:12 PM
First, make sure you are using the correct OnTriggerExit()
syntax:
function OnTriggerExit(other : Collider)
{
// Disable MouseLook script
}
If you are, then why don't you try re-enabling the MouseLook script in the same function where you destroy the wall? That would seem more logical, unless you use OnTriggerExit()
for other purposes in your game.
I'm still trying to learn how to change a variable on one gameObject script with a script from a different gameObject. IE: Disabling mouselook on the FPS controller with a script attached to the trigger. Perhaps thats the core of my problem that I need to learn.
You could use GameObject.Find("First Person Controller").GetComponent("$$anonymous$$ouseLook").enabled = true; to disable a $$anonymous$$ouseLook script attached to a GameObject named "First Person Controller".
Your answer
Follow this Question
Related Questions
OnTriggerEnter/Exit called unexpectedly 2 Answers
Turning script not enabling/disabling? 1 Answer
On trigger exit not working 2 Answers
collider trigger to disable/enable script 1 Answer
OnTriggerEnter mesh collider problem 1 Answer