Page 1 of 1
Pause a conversation in the dialogue
Posted: Wed Jun 22, 2022 11:57 pm
by luffyklose
Hi Tony,
I'm using the dialogue system and quest machine to develop my game, they really help a lot.
But I have a question about the dialogue system. There's a conversation and I want to pause it to find and use some items in the inventory system and resume after that. How can I make it using cutscene and continue the conversation after using the items?
I think I need add some script in the dialogue system to pause it and bind an event to recover.
Thanks
Re: Pause a conversation in the dialogue
Posted: Thu Jun 23, 2022 10:12 am
by Tony Li
Hi,
One way is to hide the dialogue UI. You can disable the dialogue UI's Canvas or use the SetDialoguePanel() sequencer command. For example, in the dialogue entry node where you want to hide the dialogue UI, use the command SetDialoguePanel(false) and wait for a message from your inventory system:
Code: Select all
SetDialoguePanel(false);
required SetDialoguePanel(true)@Message(UsedItem);
Continue()@Message(UsedItem)
In your inventory system, when the player uses an item use this C# code:
Code: Select all
PixelCrushers.DialogueSystem.Sequencer.Message("UsedItem");
Note: The sequence above handles continue button modes. If you don't require the player to click a continue button, you can simplify it to:
Code: Select all
SetDialoguePanel(false);
SetDialoguePanel(true)@Message(UsedItem)
Re: Pause a conversation in the dialogue
Posted: Thu Jun 23, 2022 11:12 am
by luffyklose
Hi Tony,
I used these code but didn't work, the text is hidden but the UI is still there. The dialogue UI object is still active.
Re: Pause a conversation in the dialogue
Posted: Thu Jun 23, 2022 1:11 pm
by Tony Li
Is your background image part of the Dialogue Panel hierarchy?
If not, you can use SetEnabled() instead of SetDialoguePanel().
1. Give a unique name to your dialogue UI's canvas, such as "DialogueCanvas".
2. Disable and enable the canvas:
Code: Select all
SetEnabled(Canvas, false, DialogueCanvas);
SetEnabled(Canvas, true, DialogueCanvas)@Message(UsedItem)
Re: Pause a conversation in the dialogue
Posted: Thu Jun 23, 2022 2:47 pm
by luffyklose
Yes, it is. If I deactivate it in the editor, it disappears normally.
Re: Pause a conversation in the dialogue
Posted: Thu Jun 23, 2022 3:08 pm
by Tony Li
Hmm, I assigned the WRPG UI to DemoScene1 and set Private Hart's first node sequence to:
Code: Select all
Camera(Closeup); {{default}};
SetDialoguePanel(false)@1;
SetDialoguePanel(true)@4;
Delay(6)
and it properly hides and shows the dialogue UI.
Two options:
1. Use SetEnabled() instead, as described above.
2. Or send a
reproduction project to tony (at) pixelcrushers.com. I'll be happy to take a look and let you know what I find.
Re: Pause a conversation in the dialogue
Posted: Thu Jun 23, 2022 3:40 pm
by luffyklose
The other problem is that I hide it using SetEnabled(Canvas, false, DialogueCanvas);, but the dialogue doesn't stop because I set it automatically.
I know there is pause and unpause method in the dialogue manager class, but how can I call it in Sequence?
Re: Pause a conversation in the dialogue
Posted: Thu Jun 23, 2022 6:31 pm
by Tony Li
Hi,
Make sure your sequence is configured to wait for a sequencer message from your inventory system. See the @Message(UsedItem) part of the example sequences above.
Another way to handle this is to record the current dialogue entry ID and then stop the conversation entirely. After the player has used an item, start the conversation from the recorded dialogue entry ID. For example:
Code: Select all
// C# code:
int currentEntryID;
...
currentEntryID = DialogueManager.currentConversationState.subtitle.dialogueEntry.id;
DialogueManager.StopConversation();
Then show your inventory system. After the player has used an item:
Code: Select all
DialogueManager.StartConversation(DialogueManager.lastConversationStarted, DialogueManager.currentActor, DialogueManager.currentConversant, currentEntryID);
Re: Pause a conversation in the dialogue
Posted: Fri Jun 24, 2022 3:51 pm
by luffyklose
I used the sequencer and it worked well.
Thank you, Tony!
Re: Pause a conversation in the dialogue
Posted: Fri Jun 24, 2022 3:52 pm
by Tony Li
Happy to help!