- Home /
Mac version mouse lock not working properly
We have a script that switches cameras on the fly. One camera has an unlocked mouse and the other has a locked mouse. On the mac version, when the mouse is unlocked, any movements made while unlocked will be cached so that once the mouse is re-locked, the camera instantly reads the cached information and moves the camera's position.
Quinn.gameObject.SetActive(false);
UI.camera.gameObject.SetActive(false);
Valor.camera.gameObject.SetActive(true);
skyCam = true;
cameraNumber = 1;
QuinnActive = false;
Screen.lockCursor = false;
SendMessage("setActive");
This one switches the perspective from the first person camera to the overhead camera and unlocks the mouse. The one below switches cameras back to the first person camera and re-locks the mouse.
Quinn.gameObject.SetActive(true);
UI.camera.gameObject.SetActive(true);
Valor.camera.gameObject.SetActive(false);
skyCam = false;
cameraNumber = 0;
QuinnActive = true;
Screen.lockCursor = true;
SendMessage("setInactive");
This is where the issue is happening. On the Windows version, this works just fine, re-locking the mouse to the center of the screen without any extraneous movement, but on the Mac, as soon as the switch happens the first person camera will read in the mouse movements and snap the first person camera.
Is this something I can fix in the code or would I have to put in Mac specific commands in order to fix the issue. If so, can I do that with the free version of Unity?
Thanks
Having this same issue. Did you ever find a solution or work around for this problem?
Answer by doublegumbo · Oct 17, 2017 at 07:49 PM
dealing with this now. was this ever answered?
try Cursor.lock$$anonymous$$ode as Screen.lockCursor is depricated if am not mistaken.
I noticed this issue a while ago as well. For my issue in particular, it was not properly locking the mouse whilst in the editor. However, when I built my project and tested it, there was no issue. Other than that, the previous comment is also accurate. Replace Screen.lockCursor with Cursor.lock$$anonymous$$ode.
I am using Cursor.lock$$anonymous$$ode - the issue persists.