When Game Is Paused, Camara Can Still Move Around.
So basically I followed a youtube tutorial to do my pause menu. But when I pause my game I can still move my camera around. Can someone help me, please? This is my code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour {
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
public void Resume ()
{
Debug.Log("Resume Is Working");
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause ()
{
Debug.Log("Pause Is Working");
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void LoadMenu()
{
Debug.Log("Load Is Working");
Time.timeScale = 1f;
SceneManager.LoadScene("Menu V3");
}
public void QuitGame()
{
Debug.Log("Quitting game...");
Application.Quit();
}
}
Please could you post the rest of the code, as this only provides half of the picture. It looks as though this code is correct, so the problem more-than-likely lies in your camera control code. Your camera control code should be reading the "GameIsPaused" variable in order to deter$$anonymous$$e whether to enable or disable the controls. By the way, is there any reason why this variable is static (this could potentially introduce bugs, as multiple instances would be sharing their state).
Answer by dennisfomichevf65 · Jun 28, 2018 at 02:39 PM
@LeeJBaxter What do you mean the rest of the code? This was all the code that is for my pause menu. Also I do not have any camera control code. Do I need to make it? Also there is no reason why the variable is static. I just followed the tutorial that said to do static.
Sorry for the confusion! I mean the script that controls the movement of your camera. I'm guessing this script will probably be attached to the Camera. If I'm correct, that script will check the "GameIsPaused" variable to decide whether it should be allowed to move or not.
@LeeJBaxter Well, see I deleted the camera because I have the first person controller that I got from one the unity packages that does not come with a script for the first person controller. $$anonymous$$aybe it did but i didn't enable it.