Question by
Kokoa404 · Nov 30, 2021 at 06:19 PM ·
scripting problemscripting beginnerpause menugameover
game over and pause menu conflicting scripts
i realized the scripts I'm using for the game over menu and the pause menu don't work together, every time i use both in the game the pause script doesnt pause the game, it only shows the image but since im new to C# and Unity i dont know what to do about it or how to change the code in order to make both work i would appreciate some help
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
void Start()
{
// Turns the image off.
pauseMenuUI.SetActive(false);
}
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;
}
GAME OVER SCRIPT
public static bool GameIsOver = false;
public GameObject gameoverUI;
void Start()
{
gameoverUI.SetActive(false);
}
void Update()
{
if (GameIsOver)
{
over();
}
else
{
adelante();
}
}
void over()
{
gameoverUI.SetActive(true);
Time.timeScale = 0f;
GameIsOver = true;
}
void adelante()
{
gameoverUI.SetActive(false);
Time.timeScale = 1f;
GameIsOver = false;
}
Comment
Your answer
Follow this Question
Related Questions
Need help with pause menu and cursor lock script conflict 1 Answer
Making a sword follow mouse movement 1 Answer
NavMesh of an automatically generated maze 0 Answers
Displaying Text on Touch Event 0 Answers
Cant add script becuase of error 2 Answers