Page 1 of 1

Dialogue continue based on Actor position in world

Posted: Sun Aug 28, 2022 11:16 am
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.

Re: Dialogue continue based on Actor position in world

Posted: Sun Aug 28, 2022 11:32 am
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.