Using OnTriggerEnter properly to trigger a conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Hyrad
Posts: 26
Joined: Fri Jan 13, 2017 5:11 pm

Using OnTriggerEnter properly to trigger a conversation

Post by Hyrad »

Hiya, just bought the asset, this is my first post here. Really amazing!
I know there was a post about this but I got lost trying to understand it. What I want to do is simple: trigger a conversation with an NPC when the player enters the NPC's sphere collider. What I have done so far:

- make sure that the npc's Sphere Collider on the NPC has the IsTrigger property set to true;
- add the Converstation Trigger component to the NPC with the trigger property set to OnTriggerEnter.
- The dialogue Manager is in the scene with an initial database assigned.

Now, what happens is that when I start the scene, the dialog is displayed right away, as if the OnTrigger condition was met. However the player is far from the NPC and I know the Sphere Collider works (as I am using it for other OnTriggerEnter events on other components).

Anything I am missing here? Or do you have a best guess that would point me in the right direction?
Many thanks,
- Jeff
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Using OnTriggerEnter properly to trigger a conversation

Post by Tony Li »

Hi Jeff,

Some other object is probably starting inside the NPC's sphere collider, causing it to detect OnTriggerEnter.

To fix this, inspect the Conversation Trigger. Expand Condition > Accepted Tags. Set the Size to 1, and set Element 0 to "Player" (without quotes). Then make sure your player GameObject's tag is set to "Player".
Hyrad
Posts: 26
Joined: Fri Jan 13, 2017 5:11 pm

Re: Using OnTriggerEnter properly to trigger a conversation

Post by Hyrad »

Thanks for the quick and concise answer. That fixed it, should have thought of it. Thanks :)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Using OnTriggerEnter properly to trigger a conversation

Post by Tony Li »

Glad I could help!
Post Reply