Skipping dialogue temporarily

Announcements, support questions, and discussion for the Dialogue System.
SuperSparkplug
Posts: 65
Joined: Fri Feb 06, 2015 3:51 pm

Skipping dialogue temporarily

Post by SuperSparkplug »

Hi there,

I have a cutscene sequence I'm doing and during this sequence, I want at one point in the conversation for the conversation box to go away or be blank while my first person controller is made to walk along a path. I want the next part of the conversation to trigger only after the animation is finished, and have the player be unable to skip through it.

As is, right now the sequence keeps the dialogue box on screen and is skipable by letting the player press the continue button or pressing an invisible blank option in the dialogue box to continue the narrative, with it even being possible in the middle of the path animation. I've set my Dialogue manager to always wait for a continue command, which I mostly want, except in specific instances. I'd also like to see if it's possible to disable parameters from the start to the end of a particular sequence. How do I set it to the way I want?
User avatar
Tony Li
Posts: 21059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skipping dialogue temporarily

Post by Tony Li »

Hi,

Here's one way to skin this cat:

Let's say your dialogue box GameObject is named "Dialogue Panel". Use the SetActive() sequencer command to hide it. The sequence below hides Dialogue Panel for 2 seconds and then shows it again:

Code: Select all

SetActive(Dialogue Panel,false);
required SetActive(Dialogue Panel,true)@2
Since the continue buttons are children of Dialogue Panel, they're also disabled for those 2 seconds. The "required" keyword ensures that the Dialogue Panel is reactivated even if the player cancels the sequence.

If you know the duration of the animation, you can hard-code it. Let's say the animation clip is 1.5 seconds and you're using Mecanim with root motion:

Code: Select all

SetActive(Dialogue Panel,false);
AnimatorPlayWait(WalkToDoor);
AnimatorPlay(Idle)@1.5;
required SetActive(Dialogue Panel,true)@1.5
Or, if you're using legacy animation:

Code: Select all

SetActive(Dialogue Panel,false);
LookAt(Door);
MoveTo(Door,,1.5);
Animation(WalkToDoor,,Idle);
SetActive(Dialogue Panel,true)@1.5
I don't like using hard-coded values. Instead, you can use ->Message and @Message syntax (more info):

Code: Select all

SetActive(Dialogue Panel,false);
AnimatorPlayWait(WalkToDoor)->Message(Arrived);
AnimatorPlay(Idle)@Message(Arrived);
SetActive(Dialogue Panel,true)@Message(Arrived)
There are a lot of ways you can approach this, depending on what you mean by "walk along a path." For example, if you're using a NavMeshAgent to navigate around obstacles, you can use the SendMessage() sequencer command to send a message to get the NavMeshAgent started.

If you want a more elaborate sequence, you could design it interactively in uSequencer, Cinema Director, or Animator Timeline Editor, and then use the corresponding sequencer command (such as "uSeq()") to kick it off.

Let me know if I can provide more details.
SuperSparkplug
Posts: 65
Joined: Fri Feb 06, 2015 3:51 pm

Re: Skipping dialogue temporarily

Post by SuperSparkplug »

Thanks, this almost works. I'm currently using

Code: Select all

SetEnabled(Animator, true, Player);
SetActive(Dialogue Panel,false);
required SetActive(Dialogue Panel,true)@10.10
The only issue I have left is that the player still has to trigger a dialogue choice to trigger the sequence, its supposed to happen right after the NPC speaks, and oddly enough, the same text (currently "...") that used to be the dialogue choice still appears as player dialogue. If the dialogue text is blank than its an invisible choice/dialogue text. I'd like the player dialogue here to be skipped entirely. I want it to just be NPC talks, goes through a sequence immediately after the player continues past the last NPC text, and then the NPC speaks immediately after the sequence is over.
User avatar
Tony Li
Posts: 21059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skipping dialogue temporarily

Post by Tony Li »

It sounds like you want two sequential NPC lines instead of alternating NPC -> PC -> NPC. Would that work? If so, what if you delete the PC node and make a direct link from the first NPC node to the second NPC node?
SuperSparkplug
Posts: 65
Joined: Fri Feb 06, 2015 3:51 pm

Re: Skipping dialogue temporarily

Post by SuperSparkplug »

That actually works pretty well. Now there's just one issue left.

If the player presses the continue button during the animation, it interrupts and stops the animation (which was a problem I had before) and with this new fix you suggested, it actually skips the NPC's last dialogue text. Is there a way to disable the continue button so that there's no way to skip or interrupt the sequence?
User avatar
Tony Li
Posts: 21059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skipping dialogue temporarily

Post by Tony Li »

If your sequence still uses "SetActive(Dialogue Panel, false)" and the continue button is a child of the Dialogue Panel hierarchy, it should automatically deactivate it.

If your continue button is not a child of Dialogue Panel, you could do something like this (assume the button's named "NPC Continue Button"):

Code: Select all

SetActive(Dialogue Panel,false);
SetActive(NPC Continue Button, false);
SetEnabled(Animator, true, Player);
(-- your other sequencer commands here --)
required SetActive(Dialogue Panel,true)@10.10;
required SetActive(NPC Continue Button,true)@10.10;
Or do you mean that this happens when the player presses Escape? The Escape key is the default key assigned to the Dialogue Manager's Input Settings > Cancel Key. Since you're using continue buttons, you may want to set Cancel Key to None and instead assign the Escape key to the continue button itself.
SuperSparkplug
Posts: 65
Joined: Fri Feb 06, 2015 3:51 pm

Re: Skipping dialogue temporarily

Post by SuperSparkplug »

Do you mean the Cancel or Cancel Conversation key? Cancel is the input parameter that allows the player to advance through the dialogue while Cancel Conversation kills the conversation entirely, correct?

I mean the Cancel key, which is Space bar. Am I missing something because if I don't have a key mapped to the Cancel key, I cannot continue conversations.
User avatar
Tony Li
Posts: 21059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skipping dialogue temporarily

Post by Tony Li »

That's good info. As I understand it, the following are true in your project:
  • The Dialogue Manager's Cancel Key is set to KeyCode.Space.
  • The Dialogue Manager's Continue Button mode is set to something that requires the player to click the continue button.
  • You've added one or more continue buttons to your dialogue UI.
When your dialogue UI shows an NPC line, it will wait until it receives an "OnContinue" message. Please check over the continue button setup instructions for Unity UI or the legacy Unity GUI to make sure your button is configured to send this message to the dialogue UI. If you're using Unity UI, add a UI Button Key Trigger component (Component > Dialogue System > Unity UI > Effects > Unity UI Button Key Trigger) to assign a key or gamepad button shortcut (i.e., KeyCode.Space). If you're using legacy Unity GUI, you can assign it directly to the GUIButton component.

It sounds like your continue button(s) may not be configured to send "OnContinue" to the dialogue UI, or maybe you just need to assign a key shortcut to the button. If the continue button doesn't send "OnContinue", the conversation will wait forever.

However, the Dialogue Manager's Cancel Key is like an escape hatch. When the player presses this key, it entirely bypasses the dialogue UI. It tells the underlying conversation controller to advance the conversation anyway. The conversation controller then cancels the current NPC line and moves on to the next line.

To summarize, it might help to do this:

1. Set Dialogue Manager > Cancel Key to KeyCode.None.

2. Assign KeyCode.Space as a key shortcut for the continue button(s).

3. Configure your continue button(s) to send "OnContinue" to the dialogue UI.
SuperSparkplug
Posts: 65
Joined: Fri Feb 06, 2015 3:51 pm

Re: Skipping dialogue temporarily

Post by SuperSparkplug »

I am a bit confused. I don't know what UI objects to plug in. The dialogue system, including the dialogue boxes, is being controlled by the Dialogue Manager. I am using a Canvas, which is currently being used for making a UI for the Unity UI Quests Tracker.
User avatar
Tony Li
Posts: 21059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skipping dialogue temporarily

Post by Tony Li »

The Dialogue System's various user interfaces -- dialogue UI, quest log window UI, and quest tracker -- are all independent.

The Dialogue System lets you build each user interface separately in whatever GUI system you want: the new Unity UI, the legacy Unity GUI, or other third party GUI systems. Most developers use one GUI system for all of their user interfaces, but it's also fine to use different GUI systems for different user interfaces.

As you've said, you're using the new Unity UI system for your quest tracker user interface.

Are you using the new Unity UI system for your dialogue UI also, or are you using the legacy Unity GUI system? (The legacy Unity GUI system uses the Dialogue System's GUIRoot, GUIButton, etc., components.)

If you're using the legacy GUI system for your dialogue UI, find your continue button or add one if it doesn't already exist in the dialogue UI. Then follow these steps to give it the functionality to actually continue the conversation.

If you're using the new Unity UI system for your dialogue UI, follow these steps.

If you're using Unity UI for your dialogue UI, you can put it under the same Canvas as your quest tracker UI if you want. For an example of this, open the example scene in Dialogue System/Scripts/Supplemental/UI/Example. In this case, your GameObject hierarchy will look something like this:

Code: Select all

Canvas
    Quest Tracker UI
        ... (your quest tracker UI elements)
    Dialogue UI
        Alert Panel
            ... (your alert panel UI elements)
        Dialogue Panel
            ... (your dialogue panel UI elements)
EventSystem
I included EventSystem above because Unity requires that every scene that has a Canvas must also have an EventSystem.
Post Reply