The player character in my project has a bunch of variables on the HUD that's currently set to global (HP, SP, lvl, name, profile, cash, rsc, rscCount, assist, assistState & buff), I hear using too many global variables can slow down a game though (not sure if this is true as I have yet to see it happen).
If I change layouts when the character collides with the layout boundary or a warp hotspot, the variables reflect any changes that happened in the previous layout.
If I choose to use private variables instead, when the character moves to another layout, the variables reset to their defaults because the character object isn't marked as global.
When the character is marked as global though, on layout change, another instance of the character is spawned that causes conflicts with the "Center view" attribute. Destroying the character object at the end of the layout resets the variables too.
If global variables don't slow down the game (again, I'm not sure of this being true) then this wouldn't be something I'd bother avoiding but if it does then I'd like to know any solutions for using private variables whose changes stay throughout layout changes otherwise I might just end up with way too many global variables which include unlocks, assist delays, weather, day phase, combo count and the basic variables (HP, SP, etc.) for about 5 separate characters due to possible multiplayer that I'd like to implement.
Many thanks for any help offered.