- Home /
The question is answered, right answer was accepted
need help with locking the camera in Pause Menu
i have a problem, i have everything set up but when i go in pause menu and move the mouse camera in the background moves as well, can anyone help me with it?
my code for pause menu:
public class PauseMenu : MonoBehaviour {
public Transform PauseMenu1;
public Transform Player;
void Update() {
if (Input.GetKeyDown(KeyCode.Escape))
Pause();
}
public void Pause ()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (PauseMenu1.gameObject.activeInHierarchy == false)
{
PauseMenu1.gameObject.SetActive(true);
Time.timeScale = 0;
}
else
{
PauseMenu1.gameObject.SetActive(false);
Time.timeScale = 1;
}
}
}
}
its not a first person controller. camera is like roll a ball tutorial except mine one can rotate left and right.
Add a bool for Paused to either this class or your players class. Then set it to true/false when needed, and under your camera movement, check if the bool is true or false before allowing the camera to move.
Answer by Commoble · Mar 19, 2017 at 08:25 PM
Your mouse movement code in your camera script should have something like
if (!pauseMenu.gameObject.activeInHierarchy)
{
// move camera
}
else
{
// don't move camera
}
Thank you soo mutch, all i did is:
if (Pause$$anonymous$$enu1.gameObject.activeInHierarchy) { turnSpeed = 0; } else turnSpeed = 7.0f; } }