Problem description: My cursor is still stuck in middle despite the fact that I unlock it in script. It is visible in middle though. Also whenever I press inventory button it goes back to middle. I have tried to disable looking code for debug purpose but it doesn’t work.
Relevant snippets of code:
if (Input.GetKeyDown(KeyCode.I))//enable inventory script
{
openInventory = !openInventory;
}
if (openInventory == true)
{
ShowInventory();
foreach (Transform child in weaponRoot)
{
child.gameObject.SetActive(false);//no problem in here
}
//Cursor.lockState = CursorLockMode.Confined;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
HideInventory();
Cursor.lockState = CursorLockMode.Locked;
}
Looking script:
if (Input.GetKeyDown(KeyCode.Escape))
{
if (Cursor.lockState == CursorLockMode.Locked)
{
Cursor.lockState = CursorLockMode.None;
}
else
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Dialogue with choices code snippet:
if (isTalking == true)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
Cursor.lockState = CursorLockMode.Locked;
}