Page 1 of 1

Scene / SO data -> custom actor field how to

Posted: Thu Nov 12, 2020 1:13 pm
by schmoey
Context: I'm using the Quest Machine system to initiate the Dialogue System conversations.

Trying to figure out the best (or simplest!) way to provide a custom field from a npc gameobject through to the dialogue ui, namely I want to show a model of a character instead of a sprite, so let's say I want to provide a gameobject prefab.

Putting a Dialogue Actor component on any particular quest giver object seems to be the workflow for getting actor specific data through to the dialogue system, but how would I go about adding custom fields? Subclass DialogueActor, and then get the dialogue database editor to pick it the data in the actor fields? Then finally get the data read into a custom dialogue ui class?

[...]

I did some more digging while writing this and got it going using a similar approach to https://www.pixelcrushers.com/phpbb/vie ... hp?p=16816 (substituting a render texture for the object itself)! But I would still very much appreciate your answer on this! What would you say is your ideal approach for getting custom data through to the dialogue system?

Hope this all makes sense :mrgreen:

Cheers!

Re: Scene / SO data -> custom actor field how to

Posted: Thu Nov 12, 2020 3:11 pm
by Tony Li
Hi,

Using a RenderTexture and Raw Image is the right way to show a GameObject (such as a character's 3D model) in the dialogue UI. Animmal does the same thing here in The Way of Wrath:



You can also add custom fields to the Actor template in your dialogue database -- for example, you could add a "Stance" field that specifies which animator state to play. Then use a Dialogue System Events component or the OnConversationLine script method to set the character's animator state. Something like:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    string stance = Field.LookupValue(subtitle.dialogueEntry.fields, "Stance");
    subtitle.speakerInfo.transform.GetComponent<Animator>().Play(stance);
}

Re: Scene / SO data -> custom actor field how to

Posted: Thu Nov 12, 2020 5:12 pm
by schmoey
Yessssss!

Thank you! Custom actor fields in the dialogue database is perfect!

And thanks for confirming the render texture method, I agree that seems like the best way.

:D :D

Re: Scene / SO data -> custom actor field how to

Posted: Thu Nov 12, 2020 5:29 pm
by Tony Li
Glad to help!