What's the most performant way to monitor a value from several locations?

Say I have several things that need to keep track of a single value. For instance, a UI widget, the boss, and a spawnable item all need to know how many enemies are left. When an enemy dies I would just decrement the variable on the Game Mode or level BP, then check it on tick from every location.

But someone claimed that using an event dispatcher on each enemy when they die to update each item’s local value is better because it’s less demanding. But it seems like there could be two problems.

  1. isn’t listening for an event dispatcher also listening on every tick? Is there a significant difference? (especially when there are many event dispatchers, one for each enemy)

  2. Doesn’t that introduce the possibility of bugs when each thing maintains its own value rather than getting it from a single source?

Event dispatcher doesn’t depend on tick. It registers the observers then only dispatches to them when the event happens

Ah ok, thanks.

In regard to the second part, should each observer maintain its own local value? Or should the dispatch just tell them to update from the single source?

You can just pass the latest value as param or have the observer gather it when event happens.