Mouse sometimes gets stuck in center of canvas menu screen with new Input System,
Hello!
I've been using the Starter Assets 3rd Person Controller Assets for a project (https://assetstore.unity.com/packages/essentials/starter-assets-third-person-character-controller-196526). I have several levels made from the Playground scene and a starter screen with a Start button. The starter screen is a Canvas with an image, with the player and camera deleted from the original Playground scene so the mouse is usable and visible. After the last level you return to the menu screen, I make the mouse visible with Cursor.visible = true (and with false I make it invisible after the menu) and usually it works. But sometimes after finishing the last level, when the menu reloads, the cursor is stuck in the middle and can barely move 2-3 millimeters, as if it it was stuck inside a narrow space. Does this issue ring a bell to anyone? Is there any reinit I can do to completely avoid this? Thanks for any help.
One thing that stood out was initially it happened when the character (robot) was in a landing phase of the animation. Then it started also when walking normally to the end goal that loads the menu scene. When it works, the mouse is coming from the edge of the screen, but when it's stuck it's perfectly in the middle of the screen, barely moving 1-2mm and bouncing back.
I've also enabled the setting recommended here (Project Settings > Input System Package > Update Mode; Make sure it's set to "Process Events in Dynamic Update.") because sometimes I ran into it but I've still reproduced it 1 in 3 times:
https://answers.unity.com/questions/1877166/unity-input-stutter-with-new-input-system-and-3rd.html -
Answer by valin92 · May 30 at 03:25 PM
I think I solved it with a Cursor.lockState = CursorLockMode.None; just in case there is some race condition and it stays Locked as it normally is with the character controller.