How to trigger conversation on collision using Corgi

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

How to trigger conversation on collision using Corgi

Post by lostmushroom »

Hey, I'm trying to set up a conversation that automatically triggers when you enter the ConversationZone collider, but I can't get it to work. I tried setting the Dialogue System Trigger to both 'On Trigger' and 'On Collision Enter', but nothing happens in either case. I'm using Corgi, not sure if that makes a difference.

Am I on the right track or is this totally wrong? :D
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to trigger conversation on collision using Corgi

Post by Tony Li »

Hi,

Try this:

1. Select menu item Tools > Pixel Crushers > Common > Misc > Enable Physics2D Support. (If the Console window reported "Dialogue System Trigger requires a collider but has no collider component" then this is probably the key that you're looking for. See here for more info if you're curious.)

2. Inspect the NPC's ConversationZone.
  • Tick the BoxCollider2D's Is Trigger checkbox.
  • Deactivate the ConversationZone component.
  • Change the Dialogue System Trigger's dropdown to OnTriggerEnter, and click the Add 'Player' Tag button.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: How to trigger conversation on collision using Corgi

Post by lostmushroom »

It worked, thanks!

Follow up question - is there a way to set it up so that the first time you meet this NPC, the conversation is set to OnTriggerEnter, but the next time you want to speak to them, it switches to OnUse?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to trigger conversation on collision using Corgi

Post by Tony Li »

You can have two Dialogue System Triggers, one set to OnTriggerEnter, one set to OnUse.

In the OnTriggerEnter one, in addition to starting the conversation, use OnExecute() to enable the ConversationZone and disable itself.

(To remember this in saved games, add Enabled Saver components.)
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: How to trigger conversation on collision using Corgi

Post by lostmushroom »

Probably a dumb question, but which function should I use for On Execute ()?

Also just out of curiosity, would it not work to use 'Set Components Enabled/Disabled'?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to trigger conversation on collision using Corgi

Post by Tony Li »

Yup, sorry, Set Components Enabled is simpler than OnExecute(). Use that.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: How to trigger conversation on collision using Corgi

Post by lostmushroom »

Okay, it almost works.

I added 2 Dialogue System Triggers, one set to On Trigger Enter and the other set to On Use. On the first one, I added Set Components Enabled/Disabled and set it to disable itself and enable the conversation zone.

It works up until you try to initiate conversation after talking the first time. The conversation prompt button shows up, but it doesn't start the conversation.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to trigger conversation on collision using Corgi

Post by Tony Li »

The ConversationZone is grabbing the wrong Dialogue System Trigger. Put them on two separate GameObjects. Keep the NPC configured like in the example scene, with the following changes:

1. Deactivate the ConversationZone component.

2. Add another GameObject with a trigger collider and a Dialogue System Trigger set to OnTriggerEnter. Assign the main NPC as the Conversation Conversant.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: How to trigger conversation on collision using Corgi

Post by lostmushroom »

It works now :D Thanks for all your help
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to trigger conversation on collision using Corgi

Post by Tony Li »

Happy to help! :-)
Post Reply