How best to handle NPC conversation zones active/inactive (Corgi)

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

How best to handle NPC conversation zones active/inactive (Corgi)

Post by lostmushroom »

Hi, I'm having an issue with getting NPCs to deactivate/be uninteractable at the end of a conversation, wondering what the best way to approach this is.

I have a few NPCs that once you've interacted with them, you shouldn't be able to interact with them again until the quest "Talk to X" becomes active again. At first I tried using SetActive() to switch off the conversation zone at the end of the conversation, but that was causing the player to get stuck in place (I guess because the player is still technically in the conversation).

Currently I'm using a variable on the dialogue system trigger (IsInteractable) which, if false, doesn't start the conversation. The problem is that the interactable prompts still show up, they just don't start a conversation when interacted with, which feels glitchy and clutters up the level.

I'm wondering if any of the following would work/which is best?

Option 1: In the conversation zone, there are Activation Conditions - can these be hooked up with Dialogue System variables at all? If so, the IsInteractable variable could be used here instead of the dialogue system trigger.

Option 2: Multiple dialogue system triggers, one that starts the conversation and one that deactivates the conversation zone on conversation end - not sure if this is possible or if it would glitch out.

Option 3: The Activable checkbox in the activation conditions - could this be turned on and off using the sequencer perhaps?

Alternatively maybe there is an easy solution to this I just haven't figured out :)

Thanks!
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: How best to handle NPC conversation zones active/inactive (Corgi)

Post by Tony Li »

Hi,

If the ConversationZone is on a separate child GameObject of the NPC, you should be able to deactivate its GameObject without causing problems to the NPC.

However, option 3 is your best bet. If you want to configure it in a UnityEvent, configure the UnityEvent to call ConversationZone.MakeUnactivable. Corgi will still show the activation icon, but if you try to interact with the NPC it will shake the icon instead of starting the conversation. When the quest "Talk to X" becomes active again, you can use ConversationZone.MakeActivable.

To use a sequencer command, use: SendMessage(MakeUnactivable, , NPC)
where NPC is the NPC's GameObject name.
lostmushroom
Posts: 185
Joined: Mon Jul 01, 2019 1:21 pm

Re: How best to handle NPC conversation zones active/inactive (Corgi)

Post by lostmushroom »

Thanks Tony, that looks like it will work well.

Do you know if there is a way to have the prompts not show unless activable is true, or will that require some customising?
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: How best to handle NPC conversation zones active/inactive (Corgi)

Post by Tony Li »

You may be able to make a subclass of ConversationZone that overrides that behavior.

Or you could try the first option -- deactivating the ConversationZone child GameObject, or disabling its collider.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: How best to handle NPC conversation zones active/inactive (Corgi)

Post by Tony Li »

Hi,

To disable the prompt when the zone isn't Activable, make a subclass that overrides CheckConditions(). Example:

Code: Select all

public class CustomConversationZone : ConversationZone
{
    protected override bool CheckConditions(GameObject collider)
    {
        if (!Activable) return false;
        else return base.CheckConditions(collider);
    }
}
Then replace the NPC's ConversationZone with your CustomConversationZone subclass. (See here for tips.)

This approach should work for any ButtonActivated subclass, not just ConversationZone.
lostmushroom
Posts: 185
Joined: Mon Jul 01, 2019 1:21 pm

Re: How best to handle NPC conversation zones active/inactive (Corgi)

Post by lostmushroom »

Hey Tony, thanks for your help here and on Discord (:

This is close to working as intended. I set it up with a Unity Event: CustomConversationZone.MakeUnactivable as you suggested. This plays when the conversation is started.

The only problem is that, after running MakeUnactivable, the prompt is visible all the time. It seems as though it's catching the player in the collider and getting stuck in that state.

I'm wondering if I could do something hacky and add in a line to the script that sets the prompt visuals to Alpha 0.

EDIT: I just played around with it some more. It seems that until the player moves out of the collision zone, the old behaviour stays in place (with the shaking prompt). Once you leave and come back in, the prompt is no longer responsive at all (but still visible).
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: How best to handle NPC conversation zones active/inactive (Corgi)

Post by Tony Li »

Hi,

When you run MakeUnactivable(), also run HidePrompt(). This should hide the prompt immediately and keep the prompt hidden until you run MakeActivable() and re-enter the trigger.
lostmushroom
Posts: 185
Joined: Mon Jul 01, 2019 1:21 pm

Re: How best to handle NPC conversation zones active/inactive (Corgi)

Post by lostmushroom »

Hey Tony, apologies for bumping an old thread. I've run into another issue with visual prompts.

I need to sometimes disable box collider 2Ds, but this seems to be causing a problem with the prompts. When enabled, everything is working correctly, but when disabled, the prompts are appearing at random places on screen.

This is the correct position when the box collider is enabled.
prompt1.png
prompt1.png (458.05 KiB) Viewed 608 times
This is after interacting with it, and the box collider being disabled in sequence.
prompt2.png
prompt2.png (507.78 KiB) Viewed 608 times
In the sequence field I'm using SetEnabled(BoxCollider2D, false, ShelfConversationZone). When enabling it again, it goes back to working correctly.

Thanks (:
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: How best to handle NPC conversation zones active/inactive (Corgi)

Post by Tony Li »

Hi,

Which box collider? The one on the character? Or the trigger one on the ConversationZone?

Would it be possible for you to send a reproduction project to tony (at) pixelcrushers.com?
Post Reply