Problem with Cursor

Good night,
I’m trying to use the Cursor class, but I’m having problems when using Cursor.lockState and then get the following message: “Assets / MouseLock.js (13.24): BCE0019: ‘lockCursor’ is not a member of ‘UnityEngine.Cursor’.”

I can not understand why the Unity does not recognize the ‘lockCursor’ as a member of the 'UnityEngine.Cursor "can someone help me? Below is my code. Thanks!

#pragma strict

var teste : boolean = false;

function Start () {
  
}

function Update () {
    if(Input.GetKey(KeyCode.Escape) && teste == false)
    {
        Cursor.lockState = CursorLockMode.Locked;
      
        teste = true;
    }
}

that script works perfectly well, copied it into a new js script in my testing project and it’s not throwing any errors and appears to be working when i build the project.

Should also point out that “lockCursor” isn’t anywhere in that script… so is this really the script throwing the error? lockCursor is very much not part of the cursor class:

lockState, Visible and SetCursor() are the only properties and function

1 Like

I got troubleshoot this error! The problem was my version of Unity. Thank you, but I have one more question: The cursor does not get caught in the middle, but somewhere any of the screen … How can I do to lock it in the center of the screen? Thanks!

http://forum.unity3d.com/threads/cursor-lockstate-does-not-behave-properly.337434/