Page 1 of 1

OnConversationStart actor question

Posted: Fri May 13, 2016 5:57 pm
by mandi
Hello Tony,
I have this problem: I have a custom code that is responsible for rendering a portrait of my conversant and then showing it when the conversation is ran. It works like this: I instantiate camera prefab onto transform being a child of a gameobject having dialogue trigger -> if its name is "CamAngle", a prefab is put on that transform and texture rendered. It is called OnConversationStart(). Its works fine, when I have conversation trigger mode to OnUse. But when I have OnEnable or OnTriggerEnter, it is required I put my conversant into a Speaker name of the aforementioned dialogue trigger - when the field is null, it puts that helper camera in my player's hierarchy (just under my character's trigger). Now, how to remedy this? I mean, without needing to fill Speaker with my conversant gameobject (my dialogue triggers are often reused between characters). I mean, I want the speaker field when null always refer to the object the dialogue trigger is on, I guess

I am sorry if that sounded a bit convoluted,
Best!

Re: OnConversationStart actor question

Posted: Fri May 13, 2016 10:02 pm
by Tony Li
Hello Artur,

Which trigger are you using -- Conversation Trigger, Dialogue System Trigger, or another trigger?

The Conversation Trigger and Dialogue System Trigger components have Actor and Conversant fields.

If the Conversant field is null, it uses the trigger's GameObject.

If the Actor field is null, the rules are:
  • OnBarkEnd, OnConversationEnd, OnSequenceEnd, OnUse:
    • Use the GameObject that sent the OnBarkEnd, OnUse, etc.
  • OnTriggerEnter/Exit, OnCollisionEnter/Exit:
    • Use the GameObject that entered the trigger/collider.
  • OnStart, OnEnable, OnDisable:
    • Use null -- changed in v1.6.2+.
Starting in version 1.6.2, if the actor (or conversant) is null, the Dialogue System will search the scene for a GameObject whose name matches the actor assigned to the conversation in the dialogue database. You can associate a different GameObject with an actor name in the dialogue database by adding an Override Actor Name component to the GameObject.

If you're using 1.6.2 or 1.6.2.1, please update to 1.6.2.2, which is the current version on the Asset Store. There was a bug in 1.6.2 that affected the functionality I just mentioned above. It's fixed in 1.6.2.2.

If those rules don't work for your project, you may want to write your own trigger component instead. You can grab ConversationTrigger.cs and its parent class, ConversationStarter.cs, from Scripts/SourceCode.unitypackage. The files are in Scripts/Supplemental/Triggers/Starters. You can use some of the code in them to get you started.


Another option is to assign a new portrait image to the conversation's cached actor info. Add another script with an OnConversationStart(Transform actor) method to the Dialogue Manager or one of the participants. For example:

Code: Select all

void OnConversationStart(Transform actor) {
    DialogueManager.ConversationModel.ActorInfo.portrait = myTexture2D;
}

Re: OnConversationStart actor question

Posted: Sun May 15, 2016 2:05 pm
by mandi
Hi Tony,
sorry for the delay, I am preparing for expo, will continue the thread in several days. Thank you for the answer!
Best

Re: OnConversationStart actor question

Posted: Sun May 15, 2016 2:10 pm
by mandi
Though I must say I would love to have the option like "Assign this gameobject to actor on enable" for dialogue trigger/conversation trigger (I am using both).
Best!

Re: OnConversationStart actor question

Posted: Sun May 15, 2016 3:00 pm
by Tony Li
Hi Artur,

You can assign it yourself at runtime. Would that help?

Code: Select all

// Before using the trigger, assign the desired actor:
conversationTrigger.actor = someGameObject.transform;
Good luck at the expo!

Re: OnConversationStart actor question

Posted: Sun May 15, 2016 3:44 pm
by mandi
Wow, so simple... Guess it's a sign I'm working too much... Thank you Tony!

Re: OnConversationStart actor question

Posted: Sun May 15, 2016 11:09 pm
by Tony Li
I forgot to mention one thing. Make sure you've assigned the actor before the trigger fires, for example in the Awake() method.