Handling Player stats

So, I am working on trying to improve my code flow, and make it easier for me to follow as it grows.

I am trying to figure out should I store the player data locally in the player node, or use an autoload. I have generally avoided autoloads, since usually I see warnings against overusing them.

The complication comes in with my UI character sheet that needs to display/change the player stats.

Autoload would be in my mind simpler, character sheet can change stats and player can read from them when needed.

Other way around character sheet would either need to signal up to controller that would signal over to player who would send back data to char sheet. Other method would be for character to store reference to player and call/return to get needed data.

I guess my understanding of autoloads is lacking to know if this is a bad idea, If this is setting me up to having some major challenges with the code as I move forward.

Thanks, this is more of a design question. I can implement either method I mentioned, I just don’t like the idea to refactor my code to use autoload and them realize it was a stupid idea down the road and have to refactor even more code.

I do use both local and autoload… I guess “it depends”.

But for simplicity sake, if I am planning on accessing player data in other scenes or a HUD, or if I need persistent data, I generally use an autoload.

Agreed :slight_smile:

If it’s a simple platformer with just one player, then holding player stats, like score, death count, highscore, etc. in an autoload shouldn’t be a problem, because there are no other “players” to worry about".

But if it’s an RPG, where you have a player, NPCs, wildlife creatures etc., each with their own set of stats - I would keep the stats on each of them separately, and then query that data to display in the UI whenever needed. You can have an autoload e.g. GameManager to register a reference to the player, but the data should sit on the player

Thanks, that is the conclusion I came to since it is an RPG.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.