How to pause the game when the dialogue is shown

Announcements, support questions, and discussion for the Dialogue System.
NotoMuteki
Posts: 17
Joined: Mon Oct 11, 2021 9:48 pm

Re: How to pause the game when the dialogue is shown

Post by NotoMuteki »

Thank you very much!
Now the dialogue is perfectly synchronizing with the timeline!



There are still some room for improvement,
such as when every texts has been typed out wait for 1~1.5 sec and stop timeline(to fit the timing when the player has read the text and pause the timeline. If it's too fast it feels like rage stop)
But I'll try to find the way myself.
NotoMuteki
Posts: 17
Joined: Mon Oct 11, 2021 9:48 pm

Re: How to pause the game when the dialogue is shown

Post by NotoMuteki »

And there's 1 more thing I'm thinking about.
Normally in Dialogue System, Player interact to NPC(Dialogue System Trigger) to activate Conversation.
But in my project, dialogue is controlled by timeline.
So how can I start playing timeline with Dialogue System Trigger?

As the try I wrote Sequence "Timeline(play, speaker)" in <START> entry,
But this error came out.

Code: Select all

NullReferenceException: The PlayableGraph is null.
UnityEngine.Playables.PlayableGraph.GetRootPlayableInternal (System.Int32 index) (at <31d5d65b32ec483292e13e8ae4100b93>:0)
UnityEngine.Playables.PlayableGraph.GetRootPlayable (System.Int32 index) (at <31d5d65b32ec483292e13e8ae4100b93>:0)
PixelCrushers.DialogueSystem.SequencerCommands.SequencerCommandTimeline+<Proceed>d__9.MoveNext () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Options/Timeline/Sequencer/SequencerCommandTimeline.cs:150)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <31d5d65b32ec483292e13e8ae4100b93>:0)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to pause the game when the dialogue is shown

Post by Tony Li »

Hi,

In your Dialogue System Trigger, select Add Action > OnExecute() UnityEvent instead of Add Action > Start Conversation. Configure the OnExecute() UnityEvent to start your timeline.
NotoMuteki
Posts: 17
Joined: Mon Oct 11, 2021 9:48 pm

Re: How to pause the game when the dialogue is shown

Post by NotoMuteki »

Thank you!
Now the timeline starts when the player interact NPC!

It's a small thing, but...
スクリーンショット 2021-10-21 074226.png
スクリーンショット 2021-10-21 074226.png (402.65 KiB) Viewed 503 times
An Usabe attached on NPC keeps showing in front during the conversation.(Eでインタラクト)
I think in normal Dialogue conversation it's supposed to be hidden.
Maybe because running dialogue with "OnExecute", not "Start Conversation"?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to pause the game when the dialogue is shown

Post by Tony Li »

Hi,

Add a Dialogue System Events component to the player's GameObject. Configure OnConversationStart() to disable the player's Selector component. Configure OnConversationEnd() to re-enable it.
NotoMuteki
Posts: 17
Joined: Mon Oct 11, 2021 9:48 pm

Re: How to pause the game when the dialogue is shown

Post by NotoMuteki »

Unfortunately, it didn't fix.
スクリーンショット 2021-10-21 094346.png
スクリーンショット 2021-10-21 094346.png (414.27 KiB) Viewed 501 times
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to pause the game when the dialogue is shown

Post by Tony Li »

Hi,

It will only fix it if the player GameObject is the conversation's conversation actor or conversation conversant. (Only the Dialogue Manager, the conversation actor, and the conversation conversant receive "OnConversationStart" and "OnConversationEnd" messages.)

If you want to hide the Selector even if the player isn't the actor or conversant, you'll need to add a script like this to the player:

HideSelectorDuringConversations.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

[RequireComponent(typeof(Selector))]
public class HideSelectorDuringConversations : MonoBehaviour
{
    private void OnEnable() 
    {
        DialogueManager.instance.conversationStarted += HideSelector;
        DialogueManager.instance.conversationEnded += ShowSelector;
    }
    
    private void OnDisable()
    {
        DialogueManager.instance.conversationStarted -= HideSelector;
        DialogueManager.instance.conversationEnded -= ShowSelector;
    }
    
    private void HideSelector()
    {
        GetComponent<Selector>().enabled = false;
    }
    
    private void HideSelector()
    {
        GetComponent<Selector>().enabled = true;
    }
}
Post Reply