Dialogue continue based on Actor position in world

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Aldurroth
Posts: 43
Joined: Wed Jul 20, 2022 8:44 pm

Dialogue continue based on Actor position in world

Post by Aldurroth »

I have a situation in my game where after a specific Counter/Variable has been met (Ex: 5/8 pickups) a character is activated as well as a dialogue cutscene. The player is in a room and it can activate just about anywhere. What I need to happen is that after the NPC has spoken a few words he then runs to the player. I have it set up so that a bool is activated once the NPC is close enough to the player. But it is after this point that I need the Dialogue to continue to the next part.

As of now I have a condition set up on the for the dialogue system to continue on once the bool has be switched to true. However rite now it dose not work. It may be because I have the Dialogue manager set up to only move on with button presses, but i'm not home now so i'm not sure if that's the issue.


Any idea how to get this to work? If you need a video explanation let me know.
User avatar
Tony Li
Posts: 22144
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue continue based on Actor position in world

Post by Tony Li »

Hi,

You can use a sequence for this. The key is to send a message to the sequencer when the NPC is close enough to the player. When you set the bool, also use this C# code:

Code: Select all

PixelCrushers.DialogueSystem.Sequencer.Message("CloseToPlayer");
This sends an arbitrary message "CloseToPlayer". (A message can be any string of your choosing.)

Then the most basic sequence on the dialogue entry would be:

Code: Select all

Continue()@Message(CloseToPlayer)
This will simulate a continue button click when the sequencer receives the message.

However, you can get fancier. The sequence below also hides the dialogue UI and turns off the continue button during the dialogue entry. It also calls a C# method named "MoveToPlayer()" on the NPC named "MyNPC". (I'm just making up those names for this example.)

Code: Select all

SetDialoguePanel(false);  // Hide the dialogue UI.
SetContinueMode(false);  // Turn off the continue button.
SendMessage(MoveToPlayer, , MyNPC);  // Call MoveToPlayer() on MyNPC.
required SetContinueMode(original)@Message(CloseToPlayer);  // Turn on continue button when close.
Continue()@Message(CloseToPlayer);  // Progress to next dialogue entry.
Since the sequence above hides the dialogue UI, you'll probably use this on a dialogue entry node whose Dialogue Text is blank.
Post Reply