Original Discord Post by petroslouca | 2024-08-31 00:26:52
Hello,
could you please provide a simple example in the case that there are more than one NPC’s in a Unity3D scene, on how to invoke a specific narrative trigger included in the narrative design of one of the NPCs, using a script that is attached to a new/empty game object?
So, create a new Gameobject with a script like the following attached to it:
using Convai.Scripts.Narrative_Design;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Convai.Scripts.Utils;
using Convai.Scripts;
public class NarrativeDesignManualTrigger : MonoBehaviour
{
[Header(“AVATAR MEDIEVAL OUTLANDER DATA”)]
[Tooltip(“CONVai NPC”)]
public ConvaiNPC convaiNPC_MedievalOutlander;
//[Tooltip(“CONVai NPC GO for accessing the collider’s radius”)]
//public GameObject convaiNPC_MedievalOutlander_GO;
// Start is called before the first frame update
void Start()
{
convaiNPC_MedievalOutlander = GetComponent<ConvaiNPC>();
}
public void WelcomeTrigger()
{
ConvaiNPCManager.Instance.SetActiveConvaiNPC(convaiNPC_MedievalOutlander);
if (convaiNPC_MedievalOutlander.TryGetComponent(out NarrativeDesignTrigger narrativeDesignTrigger))
{ narrativeDesignTrigger.InvokeSelectedTrigger();
}
}
It is important to have the avatar talking even if not directly having the user’s crosshair on it, as I understand that narrative trigger can be used to have the avatar acting/talking on a user’s event, e.g. approaching a specific game object.
Could you provide additional reousrces to the documentation (Adding Narrative Design to your Character | Documentation) for a more detailed information about invoking triggers from a script? An online video (YouTube) specifically on this aspect, would be really helpful!
Embedded Content: Adding Narrative Design to your Character | API Docs
Follow this guide to incorporate Narrative Design into your Convai-powered characters. Follow this step-by-step tutorial, open your project, and let’s begin!
Link: Adding Narrative Design to your Character | Documentation
Reply by petroslouca | 2024-08-31 23:10:56
So, create a new Gameobject with a script like the following attached to it:
using Convai.Scripts.Narrative_Design;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Convai.Scripts.Utils;
using Convai.Scripts;
public class NarrativeDesignManualTrigger : MonoBehaviour
{
[Header(“AVATAR MEDIEVAL OUTLANDER DATA”)]
[Tooltip(“CONVai NPC”)]
public ConvaiNPC convaiNPC_MedievalOutlander;
//[Tooltip(“CONVai NPC GO for accessing the collider’s radius”)]
//public GameObject convaiNPC_MedievalOutlander_GO;
// Start is called before the first frame update
void Start()
{
convaiNPC_MedievalOutlander = GetComponent<ConvaiNPC>();
}
public void WelcomeTrigger()
{
ConvaiNPCManager.Instance.SetActiveConvaiNPC(convaiNPC_MedievalOutlander);
if (convaiNPC_MedievalOutlander.TryGetComponent(out NarrativeDesignTrigger narrativeDesignTrigger))
{ narrativeDesignTrigger.InvokeSelectedTrigger();
}
}