How to Reference Dialogue Trigger to Auto-Detect Player?
Posted: Mon Mar 20, 2023 2:08 am
Hi, sorry if this has been asked before I couldn't find anything in the search bar, but I'm trying to get my Conversation Conversant NPCs to auto-detect my Conversation Actor, which is my player, so that if I start in another scene and enter a scene with an NPC, it will auto detect my player. I'm writing a secondary script attached to the same NPC that the Dialogue System Trigger script is on that looks like this:
Unity says the namespace DialogueSystemTrigger can't be found. So I'm trying to figure out the best way to reference the script and what the variable for the Conversation Actor is called so that I can call to it and automatically fill in the field with the player. I'm sure I'm not the first person who's needed to do this, so any help would be appreciated.
Code: Select all
public Transform player;
public DialogueSystemTrigger dTrigger;
void Start()
{
dTrigger = GetComponent<DialogueSystemTrigger>();
if (player == null)
{
player = GameObject.FindWithTag("Player").GetComponent<Transform>();
if (player !=null)
{
dTrigger.ConversationActor = player;
}
}
}