Pausing a conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tougon
Posts: 7
Joined: Mon Sep 07, 2020 12:15 pm

Pausing a conversation

Post by Tougon »

Hello!

I'm having issues pausing dialogue sequences. If I use DialogueManagerInstance.Instance.Pause, it freezes the timescale as well. Is there a way to pause dialogue without affecting timescale? I thought it might have to do with my dialogue time mode being Gameplay but when I set it to Realtime nothing changed.

Thanks!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Pausing a conversation

Post by Tony Li »

Hi,

Setting Dialogue Time to Realtime should do it, as this won't freeze timescale. It will only stop the internal clock used by the Dialogue System (including sequencer commands). What isn't working?
User avatar
Tougon
Posts: 7
Joined: Mon Sep 07, 2020 12:15 pm

Re: Pausing a conversation

Post by Tougon »

Hello!

The problem I'm facing is we need the dialogue time to be set to gameplay for this project. I've implemented a skip for cutscenes which is functional, but I would prefer that dialogue freeze before we fade out. If I attempt to change the dialogue time in code, it freezes the entire game even if I wait a frame before executing the pause. I've tried setting the dialogue time to realtime in the editor before playing and it gives the same problem. I know the issue is related to timescale sense I am able to press the pause button to unpause the game, at which point everything behaves normally, and if I set TimeScale to 1 after pausing the sequence, the game no longer freezes, but the pause is ignored.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Pausing a conversation

Post by Tony Li »

Hi,

What's the reason for setting Dialogue Time to Gameplay?

Here are what the time modes mean:
  • Gameplay: Same as Time.timeScale. DialogueManager.Pause sets Time.timeScale=0.
  • Realtime: Unrelated to Time.timeScale. Uses Time.unscaledDeltaTime, except if paused it returns 0 for delta time.
  • Custom: You must manually set DialogueTime.time and DialogueTime.deltaTime every frame. The Dialogue System will use the values you set.
Perhaps you should use Custom time? Then add a script with some methods like this to the Dialogue Manager:

Code: Select all

float timeWhenPaused;
float totalTimePaused;

public void Pause()
{
    timeWhenPaused = Time.time;
    DialogueManager.Pause();
}

public void Unpause()
{
    totalTimePaused += Time.time - timeWhenPaused;
    DialogueManager.Unpause();
}

void Update()
{
    if (DialogueTime.isPaused)
    {
        DialogueTime.time = timeWhenPaused;
        DialogueTime.deltaTime = 0;
    }
    else    
    {
        DialogueTime.time = Time.time - totalTimePaused;
        DialogueTime.deltaTime = Time.deltaTime;
    }
}
Post Reply