Using the MouseLook script in the standard assets project, How would I disable the script when a button is pressed?
Here's the set up: I have a script that Hides the Cursor (for fps sake) unless you press the "Left Alt" button. When you press Left Alt, the cursor shows back up. That works fine. However, I'd like the MouseLook Script to be disabled when I press the Left Alt Button and then Re Enabled when I release the Left Alt Button.
By Doing this, I could adjust options, or select objects on the screen without the camera continuing to rotate.
Thanks for any help!
asked Apr 26 '10 at 09:18 PM
Use GetComponent to get a reference to the script, and set enabled to false or true as necessary. Use GetButton rather than hard-coding keys, so it can be changed by the user easily (in a stand-alone anyway).
answered Apr 27 '10 at 12:16 AM
Use a boolean variable that gets set to true on left alt down, and set to false on left alt up. Then, in your mouselook script, add an if statement surrounding the mouselook part of the script. If it's not true (alt isn't held down) then you can rotate. if it is true (alt is held down) than it can't move.
EDIT: Here's a JS mouselook.