Page 1 of 1

ink: getting actor object

Posted: Tue May 19, 2020 11:37 am
by jrbourne
Hi Tony:

I'm trying to get an actor object in behavior designer that is passed as a variable from dialogue system. If I use the "Get Dialogue System as String" task , it would seem logical to me that I could get a variable from the Dialogue System that has the current Actor object (or that I could use to find the object) as specified with the #Actor tag in the ink file. So, in the example from around the world in 80 days, I might want to access the player avatar in the Unity world and change facial expressions. Or switch between actors in Unity world as the dialogue changes. I see how the actor has been specified in Dialogue System and appears in the dialogue shown in the game window - and so intelligently changes as the actor changes in the ink script (very nice). Now, if I could figure out how to get a pointer to the different actor objects in Unity as their dialogue changes in ink, I would be able to move forward. Thanks in advance for your advice on how to do this.

John

Re: ink: getting actor object

Posted: Tue May 19, 2020 12:50 pm
by Tony Li
Hi John,

With each line, the Dialogue System runs the event "OnConversationLine". You can add a Dialogue System Events component or a script to the Dialogue Manager that has an OnConversationLine method:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    GameObject currentActorGameObject = subtitle.speakerInfo.transform.gameObject;
}
You can also check DialogueManager.currentConversationState at any time that a conversation is active:

Code: Select all

currentActorGameObject = DialogueManager.currentConversationState.subtitle.speakerInfo.transform.gameObject;
If you're using Ink, you can also use the Sequence() function in your Ink stories, such as:

Code: Select all

Sequence("AnimatorPlay(Smile)")
This will play the animator state "Smile" on the current speaker's animator.

Re: ink: getting actor object

Posted: Tue May 19, 2020 1:01 pm
by jrbourne
Thanks Tony!

Are any of these methods accessible via Behavior Designer? I've been attempting to use BD - but could switch to code if that is the best way to accomplish these things. Or if there are better ways, let me know. I'm not very good with coding and would rather use other methods than coding, if possible......

John

Re: ink: getting actor object

Posted: Tue May 19, 2020 1:13 pm
by jrbourne
the other question I meant to ask was how to use the speaker actor to switch the camera between actors when the conversation changes to different actors....

Thanks Tony,

John

Re: ink: getting actor object

Posted: Tue May 19, 2020 2:05 pm
by Tony Li
Hi,

There isn't a task to get the current speaker, but I can add it to the to-do list.

If you want to change the camera focus to each line's current speaker, inspect the Dialogue Manager GameObject. Set Display Settings > Input Settings > Default Sequence to:

Code: Select all

Camera(default);
Delay({{end}})
By default, this will cut to a closeup of the speaker. If you want to specify a different default camera angle for a specific actor, add a Default Camera Angle component.

If you want to do something different for a specific line, use the Sequence() function I mentioned above.