I’m trying to figure out the most efficient way to store information about a level (name, description, thumbnail, high score, etc) so that I’m able to access and update it throughout the game.
Currently I have a “LevelInfo” struct created that contains a number of variables.
I create a LevelInfo array in the Game Instance and fill that in (say what the level file is called, give it a text name/description).
Placed in each level is an actor (which I use Get All Actors of Class to reference) that contains an integer defining the level’s index in the array (I set this manually myself).
Whenever I want to know something about the level like its name or current high score (so I can display it on UI), I’ll cast to the Game Instance and get the LevelInfo array. Using the index from the actor means I can get the specific array index I need.
If I want to change the high score for a certain level, I’ll get the LevelInfo array from a SaveGame, edit it, then save the SaveGame (I haven’t set this up yet but fingers crossed it works).
I just thought I’d pop a message on here to see if anyone else has better ideas, as currently it feels a bit messy.
I’m not an amazing programmer, but it seems like what you’re doing is good.
To my knowledge, you can’t communicate directly with the level blueprint, so even if you stored all this info directly on there, you wouldn’t be able to get it
Instead of giving each level a unique index, you could just use the level name instead. You could have an array of all your level names, then when the level loads, use GetLevelName to identify it. Then you would be able to remove that actor from each level