Hello,
What do I put in the function to get it to activate my dialogue? Can it be done in 2D hopefully? Thanks, brolol07
OnTriggerEnter2D code
Re: OnTriggerEnter2D code
Hi,
First make sure your scene has a Dialogue Manager, and that you've assigned your dialogue database to the Dialogue Manager's Initial Database field. If you haven't done that yet, I recommend going through the 5-Minute Ultra-Quick Start tutorial.
Then just call DialogueManager.StartConversation. Provide the conversation's title and the transforms of the 2D characters:
The transforms are optional, but they let you use the keywords 'speaker' and 'listener' in sequencer commands.
Or you can use a Conversation Trigger or other trigger component as described in How to Set Up NPCs. If you still want to start it manually from code, you can set the trigger to OnUse and send an "OnUse" message to it:
First make sure your scene has a Dialogue Manager, and that you've assigned your dialogue database to the Dialogue Manager's Initial Database field. If you haven't done that yet, I recommend going through the 5-Minute Ultra-Quick Start tutorial.
Then just call DialogueManager.StartConversation. Provide the conversation's title and the transforms of the 2D characters:
Code: Select all
DialogueManager.StartConversation("My Conversation", player.transform, someNPC.transform);
Or you can use a Conversation Trigger or other trigger component as described in How to Set Up NPCs. If you still want to start it manually from code, you can set the trigger to OnUse and send an "OnUse" message to it:
Code: Select all
var triggerObject = GameObject.Find("MyConversationTriggerGameObject");
triggerObject.SendMessage("OnUse");