How best to keep track of level information when using c++

Hi. I’ve set up my character, enemy, bullet, etc. classes using c++ and they are parents for blueprints.
I just don’t know the best way of keeping track of some of the level data eg. enemy kills.
For example I have a c++ gamemode class and I could use that (or gameinstance) to track kills but then my umg widget needs to bind to some of this info.
So I would have to get a reference to UMG, etc.

And I have found getting references to gameinstances, umg widgets can be a bit tricky and the other day i made a typo when trying to get a reference to the gameinstance and the next thing i know i had that error where the project hangs at 71% when trying to load.

So just wondering whether after the intial setup of the game with spawning enemies, etc. the best way to handle dynamically chaiging info is just to do it via blueprints eg. I can get all the enemies with “Get all actors of class”.

Just wondering how people handle this.


For my project, on the Hud loading I bind to ‘Refresh’ events that fetch data from the relevant actor when data changes (Have these in my Character/GameMode, but could be whereever).
You could store pointers to the actors you need data from in your Hud widget and read when Refresh is triggered.

Use a custom worldsettings class. They are saved with the level. (imo kind of misnamed class)

I think you’re actually looking for GameState.