What are the consequences of having multiple DialogueActor with same Actor type in the scene?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

What are the consequences of having multiple DialogueActor with same Actor type in the scene?

Post by fkkcloud »

Hi,

What are the consequences of having multiple DialogueActor with same Actor type in the scene?

For example, if I have 2 separated objects - each has DialogueActor component on its top hierarchy. Actor type is same e.g John.

From the Conversation, if I set AnimatiorTrigger(Idle) while John is speaking, would both Animator get the trigger?

Following up question, if one of the gameObject is inactive, then would it prioritize the active one?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: What are the consequences of having multiple DialogueActor with same Actor type in the scene?

Post by Tony Li »

It is usually best if your scene only has one Dialogue Actor assigned to an actor.

The Dialogue System maintains an internal dictionary of Dialogue Actors. When a Dialogue Actor's OnEnable() method runs, it is assigned to the dictionary entry for the actor name, overwriting the dictionary entry if it was already set by another Dialogue Actor. When a conversation starts, it checks this dictionary to associate GameObjects with actors.

For example, say you have GameObjects named GO1 and GO2. Both of the have a Dialogue Actor component set to "John".

When GO1's Dialogue Actor runs OnEnable(), it sets the dictionary[John] = GO1.

When GO2's Dialogue Actor runs OnEnable(), it overwrites the dictionary[John] = GO2.

If only one GameObject is active at a time, that's fine. Whenever you activate a GameObject, its OnEnable() method runs.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: What are the consequences of having multiple DialogueActor with same Actor type in the scene?

Post by fkkcloud »

Tony Li wrote: Fri Nov 27, 2020 8:33 am When GO1's Dialogue Actor runs OnEnable(), it sets the dictionary[John] = GO1.

When GO2's Dialogue Actor runs OnEnable(), it overwrites the dictionary[John] = GO2.
For this case, if I make GO2 to be SetActive(false) later, then GO1 would have priority?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: What are the consequences of having multiple DialogueActor with same Actor type in the scene?

Post by Tony Li »

Only if you disable and re-enable GO1.
Post Reply