Page 1 of 1

Cancel dialogue anytime

Posted: Tue May 23, 2023 6:25 am
by fr4231
Hello,

Having a bit of an issue with cancelling dialogues.
It’s set to ESC and it seems to be actually working fine but only if the conversation is at a line by the Player. Press ESC and the dialogue closes as expected.
However doing the exact same thing while an NPC is talking nothing happens, the dialogue just jumps to the next line without closing the dialogue.
Is it the expected behavior or am I doing something wrong?
How should I set things up so by pressing ESC regardless of the actor the dialogue could closed?
Thank you.

Re: Cancel dialogue anytime

Posted: Tue May 23, 2023 7:54 am
by Tony Li
That's the default behavior.
  • If the conversation is showing a subtitle (e.g,. NPC line), it listens for the Cancel Subtitle Input. If the player presses the Cancel Subtitle Input, it cancels the subtitle.
  • If the conversation is showing a response menu, it listens for the Cancel Conversation Input. If the player pressed the Cancel Conversation Input, it cancels the entire conversation.
If you want to do something different, disable both of these inputs by setting their Key values to None. Then add a script like this to the Dialogue Manager:

Code: Select all

using UnityEngine;
using PixelCrushers;
using PixelCrushers.DialogueSystem;
public class CancelConversationOnEsc : MonoBehaviour
{
    void Update()
    {
        if (DialogueManager.isConversationActive && InputDeviceManager.IsKeyDown(KeyCode.Escape))
        {
            DialogueManager.StopAllConversations();
        }
    }
}

Re: Cancel dialogue anytime

Posted: Fri May 26, 2023 9:52 am
by fr4231
worked nicely, thank you!

Re: Cancel dialogue anytime

Posted: Fri May 26, 2023 10:01 am
by Tony Li
Glad to help!