IncRelationship not working
-
- Posts: 22
- Joined: Wed Aug 19, 2020 2:44 pm
Re: IncRelationship not working
That returns Fred.
Last edited by Sternutation on Thu Sep 17, 2020 4:31 pm, edited 2 times in total.
Re: IncRelationship not working
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.
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.
-
- Posts: 22
- Joined: Wed Aug 19, 2020 2:44 pm
Re: IncRelationship not working
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.
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
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
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));
}
}