i use this as my mouse look script;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mouselook : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
it works!!
then i use this (pretty simple) as my pausemenu script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class pausmenu : 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 LoadMenu()
{
SceneManager.LoadScene("menu");
}
public void QuitGame()
{
Debug.Log("QUIT wohoo");
Application.Quit();
}
}
also works IF my mouse look scirpt isnt activated. what i mean by that is: if i have mosue look script activeated on my player camera, i cant press the buttons on my pausemenu. it does pop up when i press esc, but when i press a button my mouse just dissapears. also when i hover my buttons nothing happens. if i deactivate my mouse look script, everything works… can someone please tell me what it is thats making my pausmenu not work (it must be in the mouse look script)