Pause Game During Conversation not resuming the game after dialogue has ended

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
OddCommand24
Posts: 5
Joined: Thu Mar 24, 2022 2:03 pm

Pause Game During Conversation not resuming the game after dialogue has ended

Post by OddCommand24 »

Hello! I have a problem running dialogue system. The thing is that I have enabled the option to "Pause game during conversation", but the problem usually arises when the player presses any key during the conversation. If someone does that, the game doesn't resume or "unpause" when the dialogue ends, even though the scripts at the back-end are running, but the game/UI completely freezes. When I press any key during conversation after disabling the "Pause during conversation" option, the game runs perfectly, but I want to pause the game during conversation so that the player doesn't go away from the conversant. I am not sure why this is happening, because on some dialogues, the game resumes just fine after the dialogue's end, but on others, it freezes. I am guessing that I would have to explicitly tell the dialogue system when the conversation has ended so it can resume the game or I would have to disable my Player Controller when the player is busy during a conversation, but I don't know how to access those methods of the dialogue system. Any other easier solution or explanation to this problem is also welcomed. Thank you in advance!
OddCommand24
Posts: 5
Joined: Thu Mar 24, 2022 2:03 pm

Re: Pause Game During Conversation not resuming the game after dialogue has ended

Post by OddCommand24 »

Never mind, I fixed it by going to the "DialogueSystemTrigger" script and making a slight change in the OnConversationEndAnywhere() function:

Time.timeScale = 1; ----------------------------->Added this line

The game works perfectly now.
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Pause Game During Conversation not resuming the game after dialogue has ended

Post by Tony Li »

When Pause Game During Conversation is ticked, the original Dialogue System Trigger records the current Time.timeScale before starting the conversation. When the conversation ends, it set Time.timeScale back to the recorded value.

Since it's not setting Time.timeScale back to 1, this suggests that Time.timeScale was zero at the time you triggered the Dialogue System Trigger.

I recommend investigating why Time.timeScale is zero just before the conversation starts.

Also, instead of directly modifying DialogueSystemTrigger.cs, I recommend making a subclass. Otherwise you'll lose your modification when you update the Dialogue System. Losing modifications like this can be a big headache because something will stop working all of a sudden, and you might not remember why. A simple subclass to set Time.timeScale back to 1 might look like:

Code: Select all

public class MyDialogueSystemTrigger : DialogueSystemTrigger
{
    protected virtual void DoConversationAction(Transform actor)
    {
        base.DoConversationAction(actor);
        DialogueManager.instance.conversationEnded += UnpauseOnConversationEnd;
    }
    private void UnpauseOnConversationEnd(Transform actor)
    {
        DialogueManager.instance.conversationEnded -= UnpauseOnConversationEnd;
        preConversationTimeScale = 1;
        Time.timeScale = 1;
    }
}
OddCommand24
Posts: 5
Joined: Thu Mar 24, 2022 2:03 pm

Re: Pause Game During Conversation not resuming the game after dialogue has ended

Post by OddCommand24 »

I also found it odd that what caused the Time Scale to be zero when the conversation had started, due to which it was recording it as zero and not resuming the game after the dialogue's end. I think pressing any key was somehow causing the Time scale to be zero, because usually if I don't press any key during the dialogue, the game resumes most of the time, but I will try to investigate further into this issue. Regardless, thank you for the help. I appreciate it.
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Pause Game During Conversation not resuming the game after dialogue has ended

Post by Tony Li »

If you get to the bottom of it and find that it's something caused by the Dialogue System, please let me know.
Post Reply