Creating a reusable "You got an item!" message

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ZorcMedia
Posts: 3
Joined: Thu Jul 06, 2023 12:15 pm

Creating a reusable "You got an item!" message

Post by ZorcMedia »

Hi! So I'm currently working on an RPG with a text system very similar to the Pokémon Series. One feature from that dialogue system I'm looking to duplicate is the sequence when you pick up an item: It shows the name of the item you just got, and the amount, in the same generic textbox (without any name or picture attached to it), it plays a jingle and waits for an input.

I was wondering what steps I could take to automatically use this template multiple times. At the moment, I have created a sequencer command that takes the item's name and amount and adds it to the players inventory, and it also saves the name and amount in a variable inside the Dialogue Database ("LastItemGivenName" and "LastItemGivenAmount"). At the moment, after calling the sequences command, the next dialogue block just shows the player what they just got ("You got [var=LastItemGivenName]! (x[var=LastItemGivenAmount])"), which results in "You got Potion! (x2)" or something like that.

Now, my question is what other changes I could do to automate this further because my players will presumibly gain items many, many times during the game.

- Would it be possible to "buffer" a dialogue node (or even just text) in the sequencer command between its dialogue node and the following one via code? Since the text will always be the same. I have found no ways to do that though in the documentation.

- Is doing this inside of the Dialogue actually useful? Could I pause the dialogue until I show and put away an alert? Is it possible for the alert to wait for a continue button?

- How would I get rid of the picture and name for the invisible "narrator"? Following a previous forum post I created a Narrator Actor and tried attaching the Override Dialogue UI component to use a different Dialogue UI (one without a background graphic for the Character name, f.e.), but the component did not work like that from what I tried out.

I'm very grateful for any input!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Creating a reusable "You got an item!" message

Post by Tony Li »

Hi,

There are many ways to go about this.

You could show the "You got an item" message as an alert. Here's how I'd recommend doing it:
  • Inspect the Dialogue Manager GameObject, and tick Display Settings > Alert Settings > Allow Alerts During Conversations.
  • In your dialogue UI, move the Alert Panel below the Dialogue Panel so it sits on top of the Dialogue Panel visually. Resize the Alert Panel to cover the entire screen, and set the background image to be semi-opaque black with alpha = 128. Add an interior panel with a solid background to hold the Alert Text.
    -OR-
    Configure add a Canvas Group to the Dialogue Panel. Configure the Alert Panel's OnOpen() event to set the Dialogue Panel's Canvas Group > Alpha to zero to hide it. Configure OnClose() to set Alpha back to 1. Note: If your Dialogue Panel has an animator that also controls the Canvas Group, you'll have to adjust this approach slightly.
  • If you want to add a continue/dismiss button to the Alert Panel, set the Dialogue Manager's Alert Settings > Min Alert Seconds to 99999. Then add a Button to the Alert Panel. Configure its OnClick() event to call the dialogue UI's HideAlert() method.
  • Your custom sequencer command can just call something like:

    Code: Select all

    DialogueManager.ShowAlert($"You got {lastItemGiven}! {lastItemGivenAmount");
Alernatively, you could pause dialogue entirely and show the message in your own UI independently from the conversation. To pause the conversation, see: How To: Pause Dialogue In Pause Menu.
Post Reply