IncRelationship not working

Announcements, support questions, and discussion for the Dialogue System.
Sternutation
Posts: 22
Joined: Wed Aug 19, 2020 2:44 pm

Re: IncRelationship not working

Post by Sternutation »

That returns Fred.
Last edited by Sternutation on Thu Sep 17, 2020 4:31 pm, edited 2 times in total.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: IncRelationship not working

Post by Tony Li »

Can you use it instead of Variable["ConversantIndex"]?

The only catch is if the actor's Display Name (Variable["Conversant"]) is different from its Name (Variable["ConversantIndex"]). Otherwise they'll be the same -- unless you're localizing names, in which case Conversant will be the localized display name.

I'll look into why it's setting ConversantIndex to the conversation original conversant index instead of the assigned GameObject's actor.
Sternutation
Posts: 22
Joined: Wed Aug 19, 2020 2:44 pm

Re: IncRelationship not working

Post by Sternutation »

Using Actor[Variable["Conversant"]] in the Conversations worked. IncRelationship is now working.

I have temporarily set it so that ActorName will be equal to gameObject.name. DisplayName is currently gameObject.name so that works for now.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: IncRelationship not working

Post by Tony Li »

I've determined that I can't change the current behavior. But I can provide a solution.

Variable["ConversantIndex"] will always refer to the actor that is assigned to the conversation in the dialogue database, even if you're overriding that actor for a particular runtime instance of the conversation. If I were to change this, it might break other existing projects.

Instead, you can add a script like the one below to the Dialogue Manager. It will update the Variable["ConversantIndex"] to be the Actor index of the GameObject that's being used for the current runtime instance of the conversation.

SetConversantIndex.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SetConversantIndex : MonoBehaviour
{
    private void OnConversationStart(Transform actor)
    {
        if (DialogueManager.currentConversant == null) return;
        var dialogueActor = DialogueManager.currentConversant.GetComponent<DialogueActor>();
        if (dialogueActor == null) return;
        DialogueLua.SetVariable("ConversantIndex", DialogueLua.StringToTableIndex(dialogueActor.actor));
    }
}
Post Reply