Answer by Joshua
All you can do is use Screen.lockCursor to lock the cursor in the center of the screen and hide it. Don't just do it in your Awake function because if a player presses escape you'll have to...
View ArticleAnswer by terdos
As far as I know you cannot restrict the mouse from going outside the window of the application. However as stated above it is possible to lock the cursor to the center of the screen....
View ArticleAnswer by amirabiri
I found a better solution for this problem using PInvoke. This would work only on windows, but windows is the main platform that suffers from this problem I believe: #if UNITY_STANDALONE_WIN...
View ArticleAnswer by thenachotech1113
what about: Screen.lockCursor = true; i wold put this in function start and ad to the update a button to release it
View ArticleAnswer by ShivaFooL
I solved this for myself with the help of an Asset Store asset called ProMouse, which let's you set the mouse position. The script below uses that asset, toggles control with the escape key, and stops...
View ArticleAnswer by jcrosby
I know this is an old answer, but it helps to keep old answers update with current information. I found a much easier and up to date solution: Cursor.lockState = CursorLockMode.Confined; // keep...
View ArticleAnswer by KCharlier
Hi,all my projects using cursorLocked are stucked. The mouse stay there shaking at the right of the gamescreen. There has been two upgrades before this problem happens. i upgraded to unity 2019.2 and...
View ArticleAnswer by JonnyD
Just to give an update, since this topic is out of date but still high on search results, you should use: `Cursor.lockState = CursorLockMode.Confined;` This has been available since at least Unity 5.2.
View ArticleAnswer by ownerfate
This is quite a bit old, but nonetheless, My issue was the mouse wouldn't lock after minimizing the engine, and coming back to it, while it was in play mode. I found the answer to why it was happening...
View ArticleAnswer by zachseven
Wow. Lots going on here. If you have PlayMaker installed and PlayMakerGUI in your hierarchy it defaults to controlling the mouse cursor. Untick the box in the inspector that says 'Control Mouse Cursor'.
View Article