- Home /
Disable MouseLook for dialogues
I've got the Kimmons dialogue generator and when the dialogue pops up its really hard to make a choice without moving the camera view around a lot, which sometimes causes the dialogue to end. How can I make it so that mouseLook is disabled when the dialogue is triggered, and enabled when the dialogue is ended? Thanks!
Answer by Devin · Dec 08, 2010 at 10:13 PM
Make a static variable:
Static var Dialog : Boolean = false;
Then put this inside your update function:
if(Dialog){
GameObject.Find("First Person Controller").GetComponent("MouseLook").enabled = false;
GameObject.Find("Main Camera").GetComponent("MouseLook").enabled = false;
}
Keep in mind that this will only disable the MouseLook. To re-enable it use the same idea in reverse with a different If statement. I.E.
if(!Dialog){
GameObject.Find("First Person Controller").GetComponent("MouseLook").enabled = true;
GameObject.Find("Main Camera").GetComponent("MouseLook").enabled = true;
}
Then all you have to do if you want to initiate a dialog, just put
"Whatever object you put the above scipt onto".Dialog = true;
where does this code go? Into the existing mouselook.cs yes but the static variable goes where?
i'm sorry i'm noob i just love unity and i'm workin on a project atm so any help would be greatly appreciated.
Answer by _Petroz · Nov 05, 2010 at 11:11 AM
Put an 'if' statement around the mouse look code which checks if the dialog is being displayed.
if (DialogueInstance.enabled == true) {$$anonymous$$ouseLook.enabled = false;}
Like this? And you're saying I add it to the pre-existing $$anonymous$$ouseLook.js?
Your answer
Follow this Question
Related Questions
Head Look for Mecanim 1 Answer
Understanding The Mouselook C# Script 1 Answer
Unity 5 Upgrade: The name 'MouseLook' does not denote a valid type ('not found'). 0 Answers
Mouse Look Help 2 Answers
Vertical axis not working properly 0 Answers