Hi, guys!
I’m trying to work on an university assignment, and I am having some trouble to set the Pause Menu up with a Cinemachine. The Code the professor shared is this one:
using UnityEngine.SceneManagement;
using UnityEngine;
public class PauseMenuController : MonoBehaviour
{
public GameObject pauseMenuCanvas;
[B]public FirstPersonLook fpl;
public Zoom zoom;[/B]
public AudioSource aS;
private bool isPaused;
private float fixedTime;
// Start is called before the first frame update
void Start()
{
isPaused = false;
fixedTime = Time.fixedDeltaTime;
pauseMenuCanvas.SetActive(false);
}
private void PauseGame()
{
isPaused = false;
[B]fpl.enabled = false;
zoom.enabled = false;[/B]
aS.Pause();
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
Time.timeScale = 0;
Time.fixedDeltaTime = 0;
}
public void ResumeGame()
{
pauseMenuCanvas.SetActive(false);
[B] fpl.enabled = true;
zoom.enabled = true;[/B]
aS.Play();
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
Time.timeScale = 1;
Time.fixedDeltaTime = fixedTime;
}
public void GoToMainMenu()
{
ResumeGame();
SceneManager.LoadScene(1);
}
public void QuitGame()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.P))
{
isPaused = !isPaused;
//Idem "if(isPaused == true)"
if (isPaused)
{
PauseGame();
}
else
{
ResumeGame();
}
}
}
}
I understand that the parts I’ve put in Bold refer to the scripts on the Camera the professor is using. But since I’m using another Player (it’s actually Starter Assets Third Person), and it uses Cinemachines instead of C# Scripts, I have no idea on how to refer to them on the Pause Menu Script.
Would be really happy if I could get some help here!
Thank you all!