Use Playmaker to select a Dialogue Node

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Mahaut
Posts: 14
Joined: Sat Oct 10, 2020 1:21 pm

Use Playmaker to select a Dialogue Node

Post by Mahaut »

Hello :)
I have a question regarding Playmaker and Dialogue System.

I'm going to explain my situation briefly:

At some point, the player has to give a password through a TextInput box. They can try as much as they want until the Countdown reaches 0. If the Countdown reaches 0, the TextInput is removed and a dialogue line is displayed like "You failed".

To trigger the countdown I use Playmaker. Everything works fine (the way I've done it is maybe ugly haha) except the very last part (
"dialogue line is displayed like "You failed".)

Image

But, I don't know what kind of Action I should add to the Status "Time's up" ("Etat1" here, sorry it's in French, but it just means "State 1") in Playmaker to trigger a specific node in Dialogue System.

I would like to know if it's possible to select a spefic node through Playmaker.

I assume it's easy to (in case of challenge based on Countdown) but I've not found information regarding it.

Thanks a lot and Happy New Year :D
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Use Playmaker to select a Dialogue Node

Post by Tony Li »

Hi,

What about stopping the conversation and then restarting it at the "You failed" node? Example:

stopStartPlayMaker.png
stopStartPlayMaker.png (31.75 KiB) Viewed 300 times

There are no built-in actions to jump to a specific entry. If you or a programmer want to write one, the C# code would look similar to this:

Code: Select all

var state = DialogueManager.conversationModel.GetState(dialogueEntry);
DialogueManager.conversationController.GotoState(state);
Mahaut
Posts: 14
Joined: Sat Oct 10, 2020 1:21 pm

Re: Use Playmaker to select a Dialogue Node

Post by Mahaut »

Hello Tony, thanks your you reply.
In fact, Stop/StartConversation would delete the previous conversation (reset the conversation) and that's not what I expect.

I have not tried to create playmaker action yet. I can try (or ask a programmer indeed). Just a question "State" means "Entry/ID" in this case ?
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Use Playmaker to select a Dialogue Node

Post by Tony Li »

Hi,

A state corresponds to a dialogue entry. But it also specifies which links are currently valid, and markup tags in the text have been processed.

Here's an action to jump to a specific entry ID:

JumpToEntry.cs

Code: Select all

using UnityEngine;
using HutongGames.PlayMaker;

namespace PixelCrushers.DialogueSystem.PlayMaker
{

    [ActionCategory("Dialogue System")]
    [HutongGames.PlayMaker.TooltipAttribute("Jumps the active conversation to a specific entry.")]
    public class JumpToEntry : FsmStateAction
    {

        [HutongGames.PlayMaker.TooltipAttribute("The starting dialogue entry ID. Leave at -1 to start at the beginning")]
        public FsmInt entryID;

        public override void Reset()
        {
            entryID = new FsmInt();
            entryID.Value = -1;
        }

        public override void OnEnter()
        {
            if (!DialogueManager.isConversationActive)
            {
                LogError("Can't jump to entry " + entryID.Value + ". No conversation is active.");
            }
            else
            { 
                var id = (entryID != null) ? entryID.Value : -1;
                var conversation = DialogueManager.masterDatabase.GetConversation(DialogueManager.lastConversationID);
                var entry = (conversation != null) ? conversation.GetDialogueEntry(id) : null;
                if (entry == null)
                {
                    LogError("Can't find entry  " + entryID.Value + " to jump to it.");
                }
                else
                {
                    var state = DialogueManager.conversationModel.GetState(entry);
                    DialogueManager.conversationController.GotoState(state);
                }
            }
            Finish();
        }

    }

}
I'll add it to the next release's integration package.
Mahaut
Posts: 14
Joined: Sat Oct 10, 2020 1:21 pm

Re: Use Playmaker to select a Dialogue Node

Post by Mahaut »

Oh thank you so much for this solution.
I wasn't expected it but that is so cool. I'm very thankful for it.
Thanks a lot!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Use Playmaker to select a Dialogue Node

Post by Tony Li »

Happy to help!
Mahaut
Posts: 14
Joined: Sat Oct 10, 2020 1:21 pm

Re: Use Playmaker to select a Dialogue Node

Post by Mahaut »

Hey, just to let you know:
I've tested your solution, it works almost perfectly in my case (at least i can find now a workaround thanks to it) but if you want to make it more efficient/handy in the next update:

The solution allows the user to "see" the entry but not to jump: indeed, the node is displayed, but it does not drive to its related node:

Let's say, I have:

node A driving to
node B driving to
node C driving to
node D

If the Node A "jump to" the node D, then the Node will be shown this way "Node A > Node D > Node B > Node C".

I don't know if this was the result you were expected :) But thanks you a lot anyway :)
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Use Playmaker to select a Dialogue Node

Post by Tony Li »

Hmm, it should evaluate node D's links (which are none) and end the conversation there. If you're not able to get it to work and want to investigate further, please feel free to send a reproduction project to tony (at) pixelcrushers.com.
Mahaut
Posts: 14
Joined: Sat Oct 10, 2020 1:21 pm

Re: Use Playmaker to select a Dialogue Node

Post by Mahaut »

Thank you Tony :)
I'll try to find a solution, and if I can't, I'll send you something. Thanks a lot for your help
Post Reply