Programatically setting DialogueEntry field before the sequence is run

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Programatically setting DialogueEntry field before the sequence is run

Post by jlhacode »

I'm looking to implement a generic "Thank You" conversation/node where the dialogue node's actor & conversant is set to "(None)".

I can't figure out how to programmatically start a conversation with the Conversation/DialogueEntry having the right Actor. This would need to be done before the sequence for the DialogueEntry is played.

In order, my goal is this:
1. Start conversation
2. Set Actor field on the first Dialogue Entry with an ActorID (not a transform).
3. Enter the node, and have the default sequence on my DialogueManager run.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Programatically setting DialogueEntry field before the sequence is run

Post by Tony Li »

Hi,

Does it need to be set to (None)? At runtime, you can use a different actor for the conversation's primary actor or primary conversant. See: Character GameObject Assignments

The example used in that link is a general-purpose shopkeeper conversation that any number of shopkeeper NPCs can use.
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Re: Programatically setting DialogueEntry field before the sequence is run

Post by jlhacode »

Hi Tony,

It can be set to anything that gets the job done. Unfortunately, the "Generic Shopkeeper" example doesn't work for me, because I'd like to start this conversation purely from code instead of a DialogueSystemTrigger. To do so, I think I need to prepare the conversation actor beforehand with an actorID.

I know it's not how it works, but my ideal script would look like this:

Code: Select all

DialogueManager.GetConversation(conversationId).SetActorId(actorId);
StartConversation(conversationId);
or

Code: Select all

StartConversation(conversationId, actorId);
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Programatically setting DialogueEntry field before the sequence is run

Post by Tony Li »

You can start it from code just as easily. Pass the GameObject transforms to DialogueManager.StartConversation():

Code: Select all

DialogueManager.StartConversation(conversationTitle, actorTransform, conversantTransform);
Post Reply