Page 1 of 1

How to trigger conversation on collision using Corgi

Posted: Wed Jul 10, 2019 4:57 pm
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

Re: How to trigger conversation on collision using Corgi

Posted: Wed Jul 10, 2019 5:13 pm
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.

Re: How to trigger conversation on collision using Corgi

Posted: Wed Jul 10, 2019 5:20 pm
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?

Re: How to trigger conversation on collision using Corgi

Posted: Wed Jul 10, 2019 6:16 pm
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.)

Re: How to trigger conversation on collision using Corgi

Posted: Wed Jul 10, 2019 6:34 pm
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'?

Re: How to trigger conversation on collision using Corgi

Posted: Wed Jul 10, 2019 7:57 pm
by Tony Li
Yup, sorry, Set Components Enabled is simpler than OnExecute(). Use that.

Re: How to trigger conversation on collision using Corgi

Posted: Thu Jul 11, 2019 3:11 pm
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.

Re: How to trigger conversation on collision using Corgi

Posted: Thu Jul 11, 2019 3:19 pm
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.

Re: How to trigger conversation on collision using Corgi

Posted: Thu Jul 11, 2019 5:14 pm
by lostmushroom
It works now :D Thanks for all your help

Re: How to trigger conversation on collision using Corgi

Posted: Thu Jul 11, 2019 7:16 pm
by Tony Li
Happy to help! :-)