Page 2 of 2

Re: IncRelationship not working

Posted: Thu Sep 17, 2020 4:27 pm
by Sternutation
That returns Fred.

Re: IncRelationship not working

Posted: Thu Sep 17, 2020 4:31 pm
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.

Re: IncRelationship not working

Posted: Thu Sep 17, 2020 4:34 pm
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.

Re: IncRelationship not working

Posted: Thu Sep 17, 2020 8:58 pm
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));
    }
}