Page 1 of 1

How to Reference Dialogue Trigger to Auto-Detect Player?

Posted: Mon Mar 20, 2023 2:08 am
by nautiluscat
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:

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;
		}
	    }

    }
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.

Re: How to Reference Dialogue Trigger to Auto-Detect Player?

Posted: Mon Mar 20, 2023 8:45 am
by Tony Li
Hi,

You probably don't need any scripting for this. However, for future reference, to access Dialogue System stuff in your own scripts include this line at the top of the script:

Code: Select all

using PixelCrushers.DialogueSystem;
To get your Dialogue System Trigger to auto-detect the player:

1. Leave the Actions > Start Conversation > Conversation Actor field unassigned.

2. Add a Dialogue Actor component to your player, and set its Actor dropdown to the Player actor.

More info: Character GameObject Assignments