I'm watching a tutorial on Godot 4. We are creating a UI for the game. One of the elements on the UI is a resource counter. Tutorial had me create an Autoload node to contain various global counters. The tutorial's approach is that when a resource is consumed, the consumer decrements the resource count and then calls a function in the UI to display the new count. The approach used by another game engine I'm familiar with the consumer just decrements the resource count. The UI would set the display during each frame from its _process(delta) function.

What is the preferred/best/most-used approach for Godot?

    Calling the function when the count changes is more efficient, since the UI update only occurs when needed. A similar method would be to emit a signal when the change occurs, and the signal listener would update the UI.

    _process() should be as "light" as possible, since it's executed frequently.

      DaveTheCoder Thx. I was confused because a less-complete tutorial I took last week said it was ok to put things _process() if they weren't "time consuming". He was talking about complex calculations, I/O, network, etc. I didn't think anything wrong with that since the official learning track of the other game engine updated UI type stuff each frame.

      When this tutorial did it a different way, then I wondered if the per-frame updating is a problem in Godot.

      In this case, there's probably no practical difference in performance. Keeping unneeded code out of _process is just a general guideline.

      BriarSMC i find frame-by-frame is better when you have something that actually needs to update each frame, like a stamina bar or something that regenerates, when it comes to UI. After that it's all signals and functions unless I need something updated quickly - and when that happens, I usually drop a bool in to execute once so it doesn't hit each frame. (Probably not terribly efficient, but it works.)