Question by
DJPaultjeD · Jun 10, 2020 at 04:20 PM ·
timescalepause game
Time stuck at 0f after menu
Hello all!
I have a menu that triggers when the player enters a trigger. But the menu closes with a back button. I have Time.timeScale = 1f; in the code, but it stays paused.
[CODE]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HouseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;
public GameObject HouseMenuUI;
private void OnTriggerEnter(Collider Doorway)
{
if(Doorway.CompareTag("Player"))
{
if (GameIsPaused)
{
OutHouse();
}
else
{
InHouse();
}
}
}
public void OutHouse()
{
HouseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void InHouse()
{
HouseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
}
[/CODE]
Comment
Best Answer
Answer by DJPaultjeD · Jun 10, 2020 at 08:08 PM
Thanks for all your help! I found the issue. I forgot to add the On Click () function in Unity. I set that to Housemenu.Outhouse and now it works :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613000607im_/https://answers.unity.com/themes/thub/images/avi.jpg)