I'm trying to ignore all user input when my inventory window is open and am having some problems with it.
Here is the code I'm using:
public void AllowPlayerControl(bool allowControl)
CharacterMotor motor = GetComponent<CharacterMotor>();
MouseLook mouseLook = GetComponent<MouseLook>();
motor.enabled = allowControl;
mouseLook.enabled = allowControl;
This works in stopping the player moving the character and horizonal mouse movement but the player is still able to move the mouse vertically. The character controller itself was taken directly from the standard assets scripts for first person controller. What else do I need to disable to fix this?
One approach to finding out what is missing: While playing, have a look at the hierarchy and inspect the objects that might be relevant (cameras, player objects) and see which components are attached. Then disable those and see if it has the desired effect.
Another approach: Code review ... review your code to find out what is causing the effect of vertical mouse-movement. Then disable that.
The MouseLook script on the First Person Controller handles horizontal rotation, but there is also a MouseLook script attached to the Main Camera inside the First Person Controller that handles the vertical rotation. This is because when you look left/right the entire First Person Controller rotates, but when you look up/down, only the camera rotates.