- Home /
disable/enable mouselook not working?
Hey, I have the MouseLook script attached to my player and I'm trying to disable it using the following:
GetComponent(MouseLook).enabled = false;
Answer by Mike 3 · Jun 07, 2011 at 11:29 AM
You're trying to use the javascript syntax in c#
What you need to do is use the generic version:
GetComponent<MouseLook>().enabled = false
The alternative is to use the type version (which you shouldn't really do, use the above):
((MouseLook)GetComponent(typeof(MouseLook))).enabled = false;
Not sure if you'll be able to help with this one, when re-enabling the mouseLook script it rotates my character back to from 180 on the z axis to 0, any ideas why this might be?
$$anonymous$$y guess would be that you have another script or an animation that is causing that rotation, so when the $$anonymous$$ouseLook is no longer setting the rotation, it jumps back.
Your answer
Follow this Question
Related Questions
Disable a script from another script 2 Answers
switch scripts? 1 Answer
enable/disable specific components 3 Answers
Another Java to C# Conversion Question!! 1 Answer
Disable & Re-enable Script 1 Answer