How to trigger conversation on collision using Corgi
-
- Posts: 194
- Joined: Mon Jul 01, 2019 1:21 pm
How to trigger conversation on collision using Corgi
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?
Am I on the right track or is this totally wrong?
Re: How to trigger conversation on collision using Corgi
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.
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.
-
- Posts: 194
- Joined: Mon Jul 01, 2019 1:21 pm
Re: How to trigger conversation on collision using Corgi
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?
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
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.)
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.)
-
- Posts: 194
- Joined: Mon Jul 01, 2019 1:21 pm
Re: How to trigger conversation on collision using Corgi
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'?
Also just out of curiosity, would it not work to use 'Set Components Enabled/Disabled'?
Re: How to trigger conversation on collision using Corgi
Yup, sorry, Set Components Enabled is simpler than OnExecute(). Use that.
-
- Posts: 194
- Joined: Mon Jul 01, 2019 1:21 pm
Re: How to trigger conversation on collision using Corgi
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.
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
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.
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.
-
- Posts: 194
- Joined: Mon Jul 01, 2019 1:21 pm
Re: How to trigger conversation on collision using Corgi
It works now Thanks for all your help
Re: How to trigger conversation on collision using Corgi
Happy to help!