Sending Information between UI Elements, and the Player

Godot Version



I am wondering what the best way to handle sending information between UI elements, and between the player and the UI.

I have implemented two ways. The first is sending signals in between UI elements, and from the UI elements to the player. The second is by getting a reference to the player in the main UI element and sending the necessary information through functions instead of handling signals.

I’m not sure which way is best or if there is a better way than these two ways to do this. Signals are nice because the elements don’t have to be coupled, but if I introduce multiple players into the game how will the signals be affected?

Thank you for reading this, if you have any insight on how you have handled this, or have any ideas or questions, let me know!

There are two factors here :

  1. What IS easier for YOU specifically.
  2. What would be more performant.

When the performance doesn’t have that much of an impact, you decide based on what would be more organized and easier to understand for yourself. As you yourself will be the one who manages and reads this code.

Personally, I use autoloads and static references. Because they’re usually more performant and they’re actually really simple to use. You can basically get/set from any class to use the exact same static variables.

For me, signals are more for interacting with things within a scene. But the data within those objects usually checks the database. I then use that to save/load for characters, inventories, quests, etc.

But you, do you. What works. Works.

1 Like

Thank you for the reply, I’ll take your advice into account. I appreciate it!

1 Like