Showing "item received" during dialogue

Announcements, support questions, and discussion for the Dialogue System.
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Showing "item received" during dialogue

Post by jlhacode »

I'm making a pixel art 2D top down game. I would like to implement a little cutscene, but I'm not sure of the best way to do so.


The flow is as follows:

1. An NPC says "Here, take this {item_name}.

2. Player presses continue.

3. Dialogue UI hides (This is the part that worries me the most).

4. Item received animations play
- Player arms get raised like they're holding the item up
- Item fades in and moves up to the players hands

5. A separate subtitle should appear in the middle of the screen stating "You have received {item_name}!"

6. After three seconds, everything should animate out.

7. NPC Dialogue should resume on the node after the "Here, take this..." line. (This also worries me).


#3 concerns me because my UI Panel behaves in a way that completely throws me off whenever it gets disabled.
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Showing "item received" during dialogue

Post by Tony Li »

Hi,

Try this:
jlhacode wrote: Thu Oct 28, 2021 2:44 pm1. An NPC says "Here, take this {item_name}.

2. Player presses continue.

3. Dialogue UI hides (This is the part that worries me the most).
Use the SetDialoguePanel(false) sequencer command to hide the dialogue UI -- or use SetEnabled() to disable the Dialogue Manager's canvas. To use SetEnabled(), give the canvas a unique name such as DialogueCanvas. Then use SetEnabled(Canvas,false,DialogueCanvas).
jlhacode wrote: Thu Oct 28, 2021 2:44 pm4. Item received animations play
- Player arms get raised like they're holding the item up
- Item fades in and moves up to the players hands
It's probably easiest to do this using a node's Sequence. The node's Dialogue Text can be blank.
jlhacode wrote: Thu Oct 28, 2021 2:44 pm5. A separate subtitle should appear in the middle of the screen stating "You have received {item_name}!"
You could show it in a different subtitle panel or using an alert. To show it in a different subtitle panel, include the markup tag [panel=#] in the Dialogue Text, and set the Sequence to something like: {{default}}; SetDialoguePanel(true)

To show it in an alert, tick the Dialogue Manager's Alert Settings > Allow Alerts During Conversations. You can put the alert in a node's Script field.
jlhacode wrote: Thu Oct 28, 2021 2:44 pm6. After three seconds, everything should animate out.

7. NPC Dialogue should resume on the node after the "Here, take this..." line. (This also worries me).
SetDialgouePanel(true) or SetEnabled(Canvas,true,DialogueCanvas) should work.
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Re: Showing "item received" during dialogue

Post by jlhacode »

Hi Tony!

I'm running into an issue with the last step:
SetDialgouePanel(true) or SetEnabled(Canvas,true,DialogueCanvas) should work.
The continue button never gets enabled after the text finishes animating in when I call SetDialoguePanel(true)
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Showing "item received" during dialogue

Post by Tony Li »

Hmm, try adding this sequencer command: SetContinueMode(true)@Message(Typed)
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Re: Showing "item received" during dialogue

Post by jlhacode »

That doesn't seem to work unfortunately. I think I have a bit more context that can help us out.

This is my default sequence:

Code: Select all

SetContinueMode(false);
SetContinueMode(true)@Message(Typed);
Delay({{end}})
Screen Shot 2021-10-29 at 1.19.24 PM.png
Screen Shot 2021-10-29 at 1.19.24 PM.png (15.83 KiB) Viewed 1254 times

The nodes "Take this {item}" and "Here, let's test it out..." both use the default sequence

The '<Give {Item}' node has a sequence of None(), but it has an event, from a method on a singleton that I can reference, that I call that fires off the method below. ShowSignificantItemReceivedAnimationCoroutine plays a tween animation manually, and handles the dialogue panel state.

Code: Select all

    private IEnumerator ShowSignificantItemReceivedAnimationCoroutine() {
        if (DialogueManager.isConversationActive) {
            DialogueManager.SetDialoguePanel(false);
        }

        itemReceivedGroup.SetActive(true);
        tweenSequencer.StartSequence();
        Time.timeScale = 0;

        yield return new WaitForSecondsRealtime(C.DURATION_TO_SHOW_SIGNIFICANT_ITEM_RECEIVED);

        tweenSequencer.SmoothRewind();
        
        yield return new WaitForSecondsRealtime(tweenSequencer.GetSequenceDuration());

        DialogueManager.HideAlert();
        
        if (DialogueManager.isConversationActive) {
            DialogueManager.SetDialoguePanel(true);
        } else {
            Time.timeScale = 1;
        }
    }
Everything works perfectly!... except the continue button doesn't show in the last node :/
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Showing "item received" during dialogue

Post by Tony Li »

Hi,

You may need to set the Dialogue Manager's Debug Level to Info to get a better idea of what's going on.

Or you can change your Default Sequence to:

Code: Select all

Delay({{end}})
and configure the typewriter effect's OnCharacter() event to deactivate the continue button GameObject and OnEnd() to activate it. This way you don't need to worry about what the sequence is doing. The typewriter should always reliably show the continue button when it's done typing.
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Re: Showing "item received" during dialogue

Post by jlhacode »

Hey Tony. Cleaning up the continue button state handling in my default dialogue sequence, and delegating it to the typewriter unity events solved my issue.

Thanks for your help again! :D
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Showing "item received" during dialogue

Post by Tony Li »

Glad to help!
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Re: Showing "item received" during dialogue

Post by jlhacode »

Just ran into one tiny problem:

My continue button now flashes for a split second after selecting a response menu item. A breakpoint is telling me that the typewriter's OnEnd event gets hit after a menu item is selected, which would cause the issue.
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Showing "item received" during dialogue

Post by Tony Li »

Is your continue button part of your subtitle panel? Does the subtitle panel stay open while the response menu is shown?

The typewriter shouldn't be invoked at all if there's no text. Maybe the selected response trying to show subtitle text, but something in its Sequence is causing it to end immediately.
Post Reply