Page 1 of 1
OnTriggerEnter2D code
Posted: Tue Dec 01, 2015 11:43 pm
by brolol07
Hello,
What do I put in the function to get it to activate my dialogue? Can it be done in 2D hopefully? Thanks, brolol07
Re: OnTriggerEnter2D code
Posted: Wed Dec 02, 2015 12:01 am
by Tony Li
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:
Code: Select all
DialogueManager.StartConversation("My Conversation", player.transform, someNPC.transform);
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:
Code: Select all
var triggerObject = GameObject.Find("MyConversationTriggerGameObject");
triggerObject.SendMessage("OnUse");