Tried multiple times to figure this bad boy out but I’m good and stuck. Pause Menu works works beautifully except for the mouse wants to move the camera up and down while paused. I’ve set the variables for MouseLook and CursorLock to public so they can be called on but I have no clue what to do from there. Heres my Pause Menu Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ThePauseMenu : 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()
{
pausemenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause()
{
pausemenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void Quit()
{
Time.timeScale = 1f;
SceneManager.LoadScene(0);
}
}
At the MOST basic level, you could have a public variable of the script type that contains the MouseLook and CursorLock variables. You directly access them through the script variable. Note this is a poor practice but it is enough to get the functionality that you need for (I assume) a bit of messing around to learn Unity.
For something like pausing, I would either recommend considering an input handler that uses a state machine base (gameplay, menu etc) or alternatively, event based notifications.
For the latter, there are a few resources linked in a reply I posted to another question here
I was wayyyyyyy off haha! I started digging around and it turned out I made a dummy mistake when setting up my third person camera! My Player Character still had FPS camera codes inside his script which wasnt a big deal until the pause menu was disable the Third Person Cam. Thats when the FPS Cam would still have some functionality and was causing the camera movement on Pause. So I got rid of all the Camera coding inside of my Player Characters script and voila! The Camera moves no more on Pause!