Creating a debug overlay

Godot Version

Godot 4

Question

So, I’m creating a debug overlay for my game to help with diagnosing issues during development, similar to what Minecraft has. It displays various stats for the player and world which are retrieved from the respective nodes.

My question is this: what is the best way to send the stats to the overlay? Currently I have signals being emitted which sends the data to the overlay for updating, however as the number of stats increases, this could obviously get pretty overwhelming quite quickly. Also, with many of the stats needing to be updated every frame (such as velocity or position etc.), I wonder about the performance impact this would have with lots of signals.

Another option would be to group the signals per node such that each node that reports to the overlay only has 1 signal with a dictionary containing all the stats from that node, however this also leads to additional data being sent when it’s not needed (such as for values that stay the same over multiple frames).

Alternatively, I could reverse it and have the overlay request the information as it needs it (which I’ll do anyway for some things such as system information like fps etc.). This would reduce the amount of data being sent to only what’s necessary, but it also requires the overlay to keep track of the nodes itself, making it quite a tightly coupled system.

Keen to hear any advice people have regarding this or if you’ve done something similar. What worked, what didn’t, and how to minimise the performance impact.

Using a singleton might be a better approach for managing debug data. Instead of relying on multiple signals. Global debug manager can store and update stats as needed.

You can store stat values directly in the singleton or use classes whose values can be accessed from the debug overlay.

Signals are cheap. Firing off many hundreds per frame doesn’t seem to have much of an impact in my experience. If you do decide to pass dictionaries as signal arguments it shouldn’t be an issue as the actual data isn’t passed along, just a reference.