I have a widget on each of 4 local players which contains a counter that shows remaining enemies in an area. Each time an enemy is destroyed it tells the game mode which then updates each player’s HUD widget to reflect the new number of remaining enemies. Is there a better way to tell all widgets this information without looping through an array of all 4 widgets? I feel like event dispatchers are for something this but I am having trouble making them work without creating a hard reference to the gamemode. Is there a better way to do this?
short version, don’t stress about it, this is nothing for performance
longer version:
with arrays you don’t know which element changed anyway unless its a fast array so you’ll still have to loop.
Hard references aren’t always bad, especially to the GameMode which is always loaded anyway.
Event Dispatchers are just loops behind the scene anyway.
another option is Event Buses like the GameplayMessageSubsystem
But,
abstraction is usually less performant, (even interfaces) its solving a different problem
so back to the short version, dont worry about it ![]()
Clients do not have a copy of the GM. Only the server does. They do have a copy of the GameState though. Which would be the appropriate place to store and track the games various “states”.
That being said I’d use a RepNotify in the GS. In the Onrep function have it call an Event or Interface function on the Controller. Said event function would update the clients UI.
