Page 1 of 1

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

Posted: Thu Sep 12, 2024 4:22 pm
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!

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

Posted: Thu Sep 12, 2024 4:29 pm
by Zappy
I forgot to include in the code:
PlayerController = NPCController;
NarratorController = NPCController;

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

Posted: Thu Sep 12, 2024 5:20 pm
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.

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

Posted: Thu Sep 12, 2024 5:52 pm
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!

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

Posted: Thu Sep 12, 2024 7:24 pm
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 80 times

A conversation isn't limited to just two actors.