void Update problem
Hello, I created door with keypad script. Everything works fine except if the doors open Im not able to use my pause script. After doors open and i use pause script the player can rotate which doesnt happen before door script is used. I guess its because in update i called : fpsplayer.GetComponent().enabled = true; But Im not sure how to fix it. Any solutions ? Door script (screenshots) : http://imgur.com/a/fzpmE http://imgur.com/a/KmRg6
Pause Script:
public Transform canvas;
public Transform Player;
public Transform ControlsImage;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
{
Pause();
}
}
public void Pause()
{
if (canvas.gameObject.activeInHierarchy == false)
{
canvas.gameObject.SetActive(true);
Time.timeScale = 0;
Player.GetComponent<FirstPersonController>().enabled = false;
AudioListener.volume = 0;
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
ControlsImage.gameObject.SetActive (false);
}
else
{
canvas.gameObject.SetActive(false);
Time.timeScale = 1;
Player.GetComponent<FirstPersonController>().enabled = true;
AudioListener.volume = 1;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
ControlsImage.gameObject.SetActive (false);
}
}
Comment