When I use a custom controller (yeah I m struggling with this matter) the default unity rigidbodyfpscontroller , I have a problem with mouse lock, when i press on the menu screens (like inventory abilities etc.) I dont have the mouse cursor available.

I didnt have this problem when i used the default ORK cobtroller. Any way to fix that?

thank you
  • Hm, you could either add a little bit of code to your custom control to release the mouse lock in the OnDisable function of the component (which will be called when the control is blocked by ORK), or use events in your menu screens to unlock the mouse.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited January 2017
    so the problem i have is that, in the default rigibodyfpscontrollers on standard assets if you see, there is the script RigidbodyFirstPersonController that is attached to the player, and then the mouse look is handled by a MouseLook.cs script that is not attached but it is being called from RigidbodyFirstPersonController (that is what i understood from my little scripting knowledge).

    So the MouseLook.cs it doesn't disabled by ork, instead the RigidbodyFirstPersonController does.

    and inside MouseLook there is this code referring on lock:

    public void SetCursorLock(bool value)
    {
    lockCursor = value;
    if(!lockCursor)
    {//we force unlock the cursor if the user disable the cursor locking helper
    Cursor.lockState = CursorLockMode.None;
    Cursor.visible = true;
    }
    }


    and also:

    private void InternalLockUpdate()
    {
    if(Input.GetKeyUp(KeyCode.Escape))
    {
    m_cursorIsLocked = false;
    }
    else if(Input.GetMouseButtonUp(0))
    {
    m_cursorIsLocked = true;
    }

    if (m_cursorIsLocked)
    {
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
    }
    else if (!m_cursorIsLocked)
    {
    Cursor.lockState = CursorLockMode.None;
    Cursor.visible = true;
    }
    }



    Any thoughts how to do it? because the OnDisable, m_cursorIsLocked = false; that i tried it didnt work (because it doesn't been disabled i guess).
    Post edited by dlevel on
  • You just have to put this part in the OnDisable function:
    Cursor.lockState = CursorLockMode.None;
    Cursor.visible = true;

    That's what actually unlocks the cursor.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited January 2017
    Yeap Worked! (had to put this line on the actual script that gets disabled). thank you.
    Post edited by dlevel on
Sign In or Register to comment.