Okay I have looked at all the forums and tried everything I could find but nothing seems to be working. First of all I’m pretty new to this so excuse me if I say something wrong or have a horrible script. anyway the issue is I have a pause script which opens my pause menu and freezes my character. however I can still look around with camera as well as my mouse being locked and not visible. since I have tried almost everything I could find out there I’m assuming the error lies somewhere else in my script so please help if you can and thank you!!!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityStandardAssets.Characters.FirstPerson;
public class pauseScript : MonoBehaviour
{
public Canvas pauseScreen;
public Canvas quitMenu;
public Button startText;
public Button menuText;
public Button exitText;
void Start ()
{
pauseScreen = pauseScreen.GetComponent<Canvas>();
startText = startText.GetComponent<Button>();
menuText = menuText.GetComponent<Button>();
exitText = exitText.GetComponent<Button>();
pauseScreen.enabled = false;
quitMenu.enabled = false;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.P))
{
if (Time.timeScale == 1.0F)
{
Time.timeScale = 0.0F;
pauseScreen.enabled = true;
}
else
{
Time.timeScale = 1.0F;
pauseScreen.enabled = false;
}
}
}
public void ExitPress()
{
quitMenu.enabled = true;
startText.enabled = false;
menuText.enabled = false;
exitText.enabled = false;
pauseScreen.enabled = false;
}
public void ExitGame()
{
Application.Quit();
}
public void NoPress()
{
quitMenu.enabled = false;
pauseScreen.enabled = true;
startText.enabled = true;
menuText.enabled = true;
exitText.enabled = true;
}
public void MenuPress()
{
SceneManager.LoadScene(0);
}
public void ResumePress()
{
pauseScreen.enabled = false;
}
}
Is your “looking around” code using Time.deltaTime? Because it has to in order for your pause-methodic (basically changing delta time to be always zero) to work.
You should always use delta time with stuff like this, as the speed of the game will change on different hardware if you dont.
If you need stuff to work during pause (e.g. a pause animation) use Time.unscaledDeltaTime
hey FlashMuller thanks for taking the time to answer. the script I am using is the standard asset scripts provided with the FPS controller by unity.