How to open a dialogue box when a sprite is clicked ? + need help managing scenes and variables

Godot v4.1.2

Question

Hi, I am new to Godot and I would like to make a first, simple game to train. It would be some sort of point and click game. Here is how it is presented : you have a scene with object and characters. When you click a character, they talk. I would like to know how to make a dialogue appear as well as a close-up sprite of the talking character when the character is clicked. Think Ace Attorney Investigations dialogues.
I would also like to be able to customize the speech bubble. I know about a dialogue manager (I don’t remember the name, unfortunatly.) in which the (rectangular) speech bubble is always black, and I haven’t seen anyone change this. I would like to have my own drawn speech bubble.

I shouldn’t have too much issue with making the scene.
However, this raises another question : if I want to make several areas, should I make each area a scene ? or should I make them all in the same scene and simply move the camera (with a fade to black effect). This project does not have a protagonist in the sense that you will not control an actual charater, you will just explore. I might want to make an inventory system at some point, would the inventory be retained through scenes ? I’ve heard that variables and such are not retained when changing scenes, but I might be mistaken.

Thank you so much for your help !

You have two ways on how to approach this:

  • Make use of a Dialogue plugin that handles the heavy lifting to making a dialogue box appear, setting the text, having a system to advance textboxes
  • Make a system yourself.
    • Create a new dialogue scene, maybe of type Control or CanvasLayer
    • It has two Labels, one for the name of the speaker, the other for the text itself
    • it also has a button to proceed the dialogue
    • in your case, it also has a TextureRect node to display a closeup sprite of the talking character
    • If you do the system yourself, you can freely design how your dialogue box scene should look like.
  • Everytime you want a speech bubble to appear, I would send a signal out that can be connected to. maybe you have a dialogue handler. Maybe your main scene has a script to handle how to spawn a dialogue box. Either way, it will spawn a Dialogue Box with the text that you want to output.
    • Some people make use of an external JSON file or an internal Autoload Dictionary to store all dialogues.

It depends on what type of game you want to create. It would be better to manage if each area would be their own scene and you transition between areas using a screen transition. Those can be designed however you like. it’s all a design choice whether to have one big map (Cassette Beasts), or several interconnected areas (Anode Heart).

You are correct, if the inventory screen is directly inside your level scene and then you change your level, everything that is not an autoload will be wiped.

There are two approaches to this:

  • You can have an Inventory autoload that is available throughout your game and is not affected by changing scenes. This autoload holds all information. If you open up an inventory, some window pops up but the actual content (state of your inventory) is taken from the autoload.
  • You can setup your SceneTree appropriately to have specific nodes inside the SceneTree at all times. For example like this
Root Node
   - LevelContainer # You change scenes by use of add_child() and remove_child()
   - Player Character
   - UI_CanvasLayer # this is the User Interface Module that should be available all the time, but all children are hidden until you need them
      - Game Options Screen # when you press Escape, some menu appears
      - Inventory Screen # when you access your inventory, an inventory screen pops up
      - Dialogue Screen # Your dialogue screen
      - Screen Transition # Some kind of thing you display to hide your screen transition that's happening inside of the LevelContainer

Thank you for all your answers, I will do tests of different methods and see which one fits my project better