Trying to set an animated portrait to another speakers Animated portrait (with Sequencer command)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Zappy
Posts: 4
Joined: Thu Sep 12, 2024 4:14 pm

Trying to set an animated portrait to another speakers Animated portrait (with Sequencer command)

Post by Zappy »

Hi !
I have a player character and an NPC that is kind of narrating in dialogue (The player can also talk to the narrator directly, so they need to have their own dialogue actor). I want the player portrait and the Narrator to use the portrait of whatever NPC they are talking to (which is sometimes more than one!!) I need to be able to switch the player and the narrator portraits to specific NPC portraits in dialogue. I've been trying to use the find command in unity and that doesn't seem to be doing anything.
For example:
string NPCname = GetParameter(0);
string PlayerName = GetParameter(1);
string NarratorName= GetParameter(2);
GameObject NPCObject = GameObject.Find(NPCname);
GameObject PlayerObject = GameObject.Find(PlayerName);
GameObject NarratorObject = GameObject.Find(NarratorName);
DialogueActor PlayerPortrait = PlayerObject.GetComponent<DialogueActor>();
DialogueActor NarratorPortrait = NarratorObject.GetComponent<DialogueActor>();
DialogueActor NPCPortrait = NPCObject.GetComponent<DialogueActor>();
AnimatedPortrait PlayerController = PlayerPortrait.GetComponent<AnimatedPortrait>();
AnimatedPortrait NarratorController = NarratorPortrait.GetComponent<AnimatedPortrait>();
AnimatedPortrait NPCController = NPCPortrait.GetComponent<AnimatedPortrait>();
Is there an easier way to do this? :| Thank you in advance!
Zappy
Posts: 4
Joined: Thu Sep 12, 2024 4:14 pm

Re: Trying to set an animated portrait to another speakers Animated portrait (with Sequencer command)

Post by Zappy »

I forgot to include in the code:
PlayerController = NPCController;
NarratorController = NPCController;
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trying to set an animated portrait to another speakers Animated portrait (with Sequencer command)

Post by Tony Li »

Hi,

If you specify an NPC's GameObject as the conversation conversant, then the conversation will use that NPC (including its portrait(s)) as the actor.

For example, let's say you've written the conversation between two actors:
  • Actor: Player
  • Conversant: Narrator
and you have other actors named Ann and Bob.

If you pass Ann's GameObject as the conversation conversant, then Ann will speak every dialogue entry that you assigned to Narrator, and her portrait image will appear.

If that isn't what you're looking for -- for example, if you always want to use the Narrator actor -- you can use the SetPortrait() sequencer command to change the Narrator actor's portrait at runtime. If you specify an image name, SetPortrait() will look for that image in a Resources folder or addressables. You can also specify a number using "pic=#" if you've assigned multiple images to the Narrator's Portrait Sprites.
Zappy
Posts: 4
Joined: Thu Sep 12, 2024 4:14 pm

Re: Trying to set an animated portrait to another speakers Animated portrait (with Sequencer command)

Post by Zappy »

My issue is I want to be able to have multiple conversants in any one conversation. If I set Ann to conversant, won't that mean she says all of Bob's lines as well?

For the set portrait, can that sequencer command set animated portraits as well?

Thank you for the quick response!
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trying to set an animated portrait to another speakers Animated portrait (with Sequencer command)

Post by Tony Li »

Hi,

Do you want to involve multiple different actors in a single conversation? In that case, you can assign them to different dialogue entries in the conversation:

multiActorConv.png
multiActorConv.png (39.58 KiB) Viewed 59 times

A conversation isn't limited to just two actors.
Post Reply