Adding Actor Component on Runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
frankydess
Posts: 4
Joined: Sat Oct 24, 2020 11:16 am

Adding Actor Component on Runtime

Post 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?
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding Actor Component on Runtime

Post 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
frankydess
Posts: 4
Joined: Sat Oct 24, 2020 11:16 am

Re: Adding Actor Component on Runtime

Post by frankydess »

Thanks!
I'll try it right now.
That's an obviously better way to do it!
Post Reply