Page 1 of 1

Adding Actor Component on Runtime

Posted: Sat Oct 24, 2020 11:27 am
by frankydess
Hi!
The Dialogue System is fantastic!
I have an issue, i don't know if i'm either not doing it right or if the system doesn't support that.

In my database, i have actors for each of my 8 different in-game characters. Since it's a 4 player multiplayer game, the players can pick any character making a lot of possible combination. The dialogues are mostly character specific but for efficiency purpose, i want some generic dialogue targetted to Player1 so i created a "Player1" actor. I already tried in the editor and i can assign 2 DialogueActor components on my character game object and the dialogue using the bubble UI works perfectly.

However, when i add a DialogueActor component and changes the values of actor, barkUI and subtitleUI via script at runtime, it doesn't work.

My code looks like this:

Code: Select all

var dA = spawnedCharacter.AddComponent<DialogueActor>();
dA.actor = ("Player"+(slot.playerNumber+1));
dA.barkUISettings.barkUI = bubbleBarkUI;
dA.standardDialogueUISettings.subtitlePanelNumber = SubtitlePanelNumber.Custom;
dA.standardDialogueUISettings.customSubtitlePanel = bubbleSubtitleUI;
where "bubblebarkUI" and "bubbleSubtitleUI" are serializeFields set manually in the editor.

Am I doing it wrong or the dual actor component isn't meant to be supported in the first place?

Re: Adding Actor Component on Runtime

Posted: Sat Oct 24, 2020 1:10 pm
by Tony Li
Hi,

You only need one Dialogue Actor (set to the actor's name, not Player1).

Assuming your generic conversation uses Player1 as the actor, if you pass any GameObject to the DialogueManager.StartConversation("title", actor, conversant) method, it will use the Dialogue Actor on that GameObject.

If you're using a Dialogue System Trigger set to OnUse or OnTriggerEnter, leave the Conversation Actor field blank. It will use the GameObject that triggered the conversation.

More info: Character GameObject Assignments

Re: Adding Actor Component on Runtime

Posted: Sat Oct 24, 2020 7:27 pm
by frankydess
Thanks!
I'll try it right now.
That's an obviously better way to do it!