Locking only the mouse look
A look lock stops the player turning the camera with the mouse, and leaves walking free. It is counted for each mod id like Lock.
PlayerMovement stop and restore the mouse look
Call LockLook to stop the mouse look while the player can still move, and UnlockLook to give it back.
public static class PlayerMovement
{
public static bool LockLook(string modId);
public static bool UnlockLook(string modId);
}
| Method | Returns | What it does |
|---|---|---|
LockLook(modId) | bool | Stops the mouse look. false if it could not. |
UnlockLook(modId) | bool | Lets go of your newest look lock. false if you hold none. |
Things to know
LockLook(modId)stops the player’s mouse look and leaves movement free. TwoLockLookcalls from one mod need twoUnlockLookcalls. (it sets the game’s rotation flag throughThirdPersonCameraController.DisableRotation.)- The game can still turn rotation on and off itself, and your lock stays. Rotation is off while the game wants it off or any mod holds a look lock. So when the game turns rotation back on (in a chair, at a computer, on a ladder, in the cards game), it never ends your lock.
UnlockLooknever turns rotation back on if the game turned it off. (postfixes onDisableRotationandEnableRotationtrack whether the game wants rotation off. The framework’s own calls are ignored.)
Limits
LockLookreturnsfalseand takes nothing when the camera is not loaded, while a save is loading or being written, or when the rotation hooks did not set up. A bad mod id throws anArgumentException.- A single-scene load clears every look lock, and so does the player dying. The camera may be replaced, so the game’s tracked state is reset. Take your lock again from your own handler. (the death case is
Survival.PlayerDied.) - There is no event for the main menu. The main menu is loaded as a single scene.