I was wondering if, to pass variables from a scene (in this case, player.tscn) to another one (hud.tscn) it would be a good practice to do something like this:
I tried that to show the player’s stamina in the HUD of my game and it worked perfectly, but I wondered if is it really a good practice to do it this way, and/or if it’s going to slow performance.
Seems like a unnecessary copy, couldn’t you use Autoload.playerStamina everywhere need be, and remove var stamina: float = 10, similarly with max stamina.
Good point, do you think that for several scenes it is better to save the player statistics (such as stamina) in an autoload instead of in the player scene? (To make them global)
Depends on the game, maybe stamina specifically can be private information to the player. Personally, I find autoload can be avoided for most variables, gold/money is the most common autoload I use.
thank you, I’ll have that in mind and use Autoloads to store that info only if necessary (in my case I think it is because of the HUD displaying the stamina)