Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Cursor Locked.

Discussion in 'Scripting' started by Corrothon, Sep 4, 2020.

  1. Corrothon

    Corrothon

    Joined:
    Jun 11, 2019
    Posts:
    60
    I'm working on my horror game that is soon finished. I Currently Have 3 Scenes
    1. Titlescreen
    2. Game
    3. Jumpscare

    And When you enter Game your cursor locks as it should. But when you get jumpscared (and it transfers you to the jumpscare scene) the cursor remains locked.

    Here's the code for the lock cursor:

    void Start()
    {
    Cursor.lockState = CursorLockMode.Locked;
    }
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @CodyProductions

    "And When you enter Game your cursor locks as it should. But when you get jumpscared (and it transfers you to the jumpscare scene) the cursor remains locked."


    You state cursor remains locked - do you actually mean by this that it shouldn't be locked?

    If you set your cursor lock state in the Start, why couldn't you set it to other state when it no longer needs to be locked?

    https://docs.unity3d.com/ScriptReference/CursorLockMode.html
     
    Corrothon likes this.
  3. Corrothon

    Corrothon

    Joined:
    Jun 11, 2019
    Posts:
    60
    Thank you dude :) (Im just new haha)