Help with LockCursor Script

Hi everyone I'm have a little trouble with the LockCursor script that comes with the Unity3d FPS tutorial. I'm making a stand alone game for windows but for some reason the LockCursor script does not work with the stand alone platform it locks the cursor fine but when I press ESC it does not work. So is there some I have to add to the code to make it work or is there another code that will work better. I'm not much of a coder so take it easy on me.'

Thank very much for any help.

Check out Unity's documentation for Screen.lockCursor.

Disclaimer: Going to Unity's documentation will not magically solve your problem! ;)

In other words, you'll need to check for typos in your script. If your problem persists, try posting some code.

Hi Chris,

If I understand correctly your problem, the action when pressing esc has to be coded, this has nothing to do with the cursor lock actually.

Here is a code that works both when you press ESC or if you press "p". You have to code the logic of what you want to achieve when the user press ESC.

public var paused: boolean = false;

function Update()
{

    if( Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.P))
    {
        paused = !paused;

        Screen.lockCursor = !paused;

      if(paused)
        {
            Time.timeScale = 0.00001;
        }else{
               Time.timeScale = 1.0;
        }
    }
}

Also don't forget to lock the cursor in the Start function too.

Hope it Helps.

Bye,

Jean