Can I enable a Dialogue Trigger in a C# Script?
Posted: Wed Dec 11, 2024 9:49 am
Hi there, I'm currently trying to enable a conversation to trigger only when a certain variable in a C# script is true. Here is my current script, where PlayerRotation is the player object, SplineMoving is the movement script, and the Dialogue Trigger is on the object where this script is attached. I have the Dialogue Trigger set to "On Enable" but that just starts the conversation on awake. Is this something I would have to do through the Lua conditions?
Code: Select all
using System.Collections;
using System.Collections.Generic;
using PixelCrushers.DialogueSystem;
using UnityEngine;
public class DialoguePosTrigger : MonoBehaviour
{
public bool inDialogue;
public SplineMoving splineMoving;
public DialogueSystemTrigger dialogueTrigger;
// Start is called before the first frame update
void Start()
{
dialogueTrigger = GetComponent<DialogueSystemTrigger>();
splineMoving = GameObject.Find("PlayerRotation").GetComponentInChildren<SplineMoving>();
inDialogue = false;
}
// Update is called once per frame
void Update()
{
inDialogue = splineMoving.inDialogue;
if (splineMoving.inDialogue)
{
dialogueTrigger.gameObject.SetActive(true);
}
}
}