Freeze the scene when a gui window pops up

Hi guys…I ve made a script so when the player hits certain game objects a gui window pops up . During that time, I would like to freeze the scene (for 3-4 seconds) so the player can read the pop up window. I found similar questions and I think i need to use the Time.Timescale=0 and Time.TimeScale=1 but since I am not so familiar with C# i don

t know how to incorporate these functions into my existing script. Thanks in advance!

Try:

IEnumerator OnTriggerEnter()
{
            if (gameObject.CompareTag("Player"))
           {
           customText.SetActive(true); //Text appears
           Time.timeScale = 0.0f; //Stop time flow
            
            yield return new WaitForSeconds(3.5f); //Wait for 3.5 secs

           customText.SetActive(false); //Text goes away
           Time.timeScale = 1.0f; //Recover time flow
           }
} //Not tested yet...

I would not operate with ‘OnTriggerExit’, cause you can’t move out of trigger with no time running (your movement is a change of position over time) :wink:

You should start a corutine whics set timesale to 0 when it begins wait for x second than set timescale back to 1.
You can learn about coroutines here.