Question by
JesusKraisnik · Dec 03, 2016 at 06:53 AM ·
javascript
How to disable mouse lock in first person controller ?
I want to cursor be visible on pressing "2" key, I tried every script from internet, the only thing it worked is to make FirstPersonController dissabled, but that doesn't show me a cursor.
function Update () {
if(Input.GetKeyDown(KeyCode.Alpha2)){
GetComponent(FirstPersonController).enabled = false;
Cursor.lockState = CursorLockMode.None;
}
}
(this script is attached to player)
Comment
maybe you need to call
Cursor.visible = true;
because the cursor was set to invisible at some point?
Answer by Alacer · Mar 15, 2017 at 07:44 PM
So.. I tried to look for some code to disable/enable Lock Cursor that is on the First Person Controller script. Since im a noob, it took me a while to notise they are all Serializeable Privates. Edit first person controller, change [SerializeField] private MouseLook m_MouseLook
to public and then you can:
if(Input.GetKeyDown(KeyCode.M))
{
playerController.m_MouseLook.lockCursor = false;
}
Hope it helps someone out there.. cheers
Answer by novaboxes · Dec 30, 2020 at 01:00 AM
Ok
public GameObject fPA;
Pause();
#region GetComponent(public void ControllerPause = lockAndHideCursor = false);
#endregion