Hello everyone,
I’m doing a school project and I’v ran into one slight problem : I have imported the fps controller asset from unity, and at some times the player will be disabled and they will have to do some gameplay with the cursor. Now the problem is that fps controller has a public variable Lock Cursor, which locks it for the whole game and I can’t unlock it. I’v tried code lines like Cursor.LockState and Cursor.Visible and after that I tried accessing the fps controller script aswell, but had no luck. As the dead end is nearing, I don’t have the time to make a fps controller by myself because I’m fairly new to the whole Unity development.
Any help would be appreciated,
best regards.
Try making a script in the other scene and put Obstruction = Target;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked; in the void start method
It’s been about 8 years since this was posted, you’re probably a full adult with a job and responsibilities.
Anyway, I think I have the solution. In the starterAssetsInputs script on the playercapsule gameobject, there will be a cursor locked bool. All you have to do is comment out the SetCursorState(cursorLocked);
line of code in the OnApplicationFocus
method. Then, you’ll be free to lock or unlock the cursor however way you wish.
Another way is to directly use the SetCursorState
function in that script to change the mouse lockstate. just do starterAssetsInputs.SetCursorState(true or false);
, just make sure you make that method public first.
Fyi, I’m pretty sure this only works in the newer unity versions. Hope this helps!