Animated Character Portraits using Bolt

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Animated Character Portraits using Bolt

Post by F1foux »

Hi everybody,
I'm trying to replicate this behaviour: https://pixelcrushers.com/phpbb/viewtop ... 459#p23459
but in Bolt.
I got a second camera rendering to a Rendertexture. Now I want to automatically switch the cameras position depending on the current Speaker, but I can't find a function in Bolt to find out who the active speaker is. In the script they use "subtitle.speakerInfo.Transform".
Additionally I want to send the emotion of every Dialogue Entry to my Script so I can trigger the right character animations fitting to the dialogue. What would be the easiest way to achieve this? I tried adding a field called "Emotion" to every dialogue entry, but again I can't figure out how to send this information to my Bolt script.

Any help would be appreciated :D
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animated Character Portraits using Bolt

Post by Tony Li »

Hi,

To recap our email:

When a conversation starts, the Dialogue System stores the name of the conversation actor in a Dialogue System variable named "Actor" and the name of the conversant in a variable named "Conversant".

Try using this command in the Script field:

Code: Select all

BoltEventString("Dialogue_Render", "GetSpeaker", Variable["Actor"])
It will find the GameObject named "Dialogue_Render". Then it will invoke the custom event "GetSpeaker", passing it the name of the actor.


When a conversation starts, the Dialogue System will also store the index of the conversation actor in a Dialogue System variable named "ActorIndex". The index is used to look up the actor's field in the Actor[] table. In most cases, the index is the same as the name. For example, if the actor is named "Bob", the index will also be "Bob", and the Emotion field value will be Actor["Bob"].Emotion.

Certain characters are not allowed in indexes, most notably the space character and most punctuation. So if the actor's name is "Bob's Uncle", then the index will be "Bob_s_Uncle". The Emotion field will be Actor["Bob_s_Uncle"].Emotion.

Say the GameObject named "Dialogue_Render" has a custom event "GetEmotion". You can use this command in the Script field to pass the actor's emotion:

Code: Select all

BoltEventString("Dialogue_Render", "GetEmotion", Actor[Variable["ActorIndex"]].Emotion)
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Animated Character Portraits using Bolt

Post by F1foux »

Thanks again Tony. I managed to get the Actor working.

I added an Emotion field to the Conversation entries in the Templates tab. Is there also a way to read this emotion value from the current Conversation entry and send this to Bolt? This would be easier for me because I could copy/paste the same code into every Conversation entry and just change the Emotion value in the list below.

Because the emotion value always relates to the current speaker this seems easier to me. The other way I would have to rewrite the code for every Conversation entry because the speaker and emotion change.

Thanks again
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animated Character Portraits using Bolt

Post by Tony Li »

Hi,

Did you add the Emotion field to the Conversation template or to the Dialogue Entry template?

Let's say you added it to the Dialogue Entry template so each dialogue entry node can have its own Emotion.

Add a Dialogue System Bolt Custom Events component to the Dialogue Manager GameObject or one of the conversation's participants.

When each line of dialogue plays, the Dialogue System Bolt Custom Events component will raise a custom event named "OnConversationLine". In this event, you can get the value of the dialogue entry's Emotion field.

The Dialogue System will store the current conversation state in DialogueManager.currentConversationState. This in turn contains a subtitle property. The subtitle contains a dialogueEntry. And the dialogueEntry has a list of fields. You can use Field.LookupValue to look up the value of the Emotions field.

Here's an example that will look up the current line's Emotion field and show it as an alert message:

boltGetEmotion.png
boltGetEmotion.png (60.45 KiB) Viewed 484 times

(Since the alert appears during a conversation, the Dialogue Manager's Alert Settings > Allow Alerts During Conversations checkbox must be ticked.)
F1foux
Posts: 26
Joined: Mon Jul 19, 2021 1:21 pm

Re: Animated Character Portraits using Bolt

Post by F1foux »

This sounds great and it's exactly what I need. Unfortunately when I try to recreate your Bolt Node setup I get as far as "currentConversationState_get", i can't find the get subtitle function. Did I mess up something with my Bolt configuration regarding Dialogue System?
Subtitle_Get.jpg
Subtitle_Get.jpg (27.43 KiB) Viewed 481 times

EDIT: Ok got it working... I had to add Field, Dialogue Entry, List<DialogueEntry>, ConversationState, DialogueSystemFields, Subtitle, DialogueEntry to Bolts UnitOptionsWizard.

Thx for the help :)
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animated Character Portraits using Bolt

Post by Tony Li »

Glad to help! Good point - In the future, I'll mention the units that need to be added in Bolt's UnitOptionsWizard. It's a bit of a hassle that Bolt makes you add each one manually, but I guess it's good in the long run because it speeds up Bolt's editor windows to only have exactly the units you need. If you run into any other questions about using the Dialogue System with Bolt, just let me know!
Post Reply