My game features a weapon system which allows the player to pick up various weapons and use them. There are different properties for each weapon, such combo set and attack speed, and these are stored in the variables of each weapon. When a weapon is picked up, these will b loaded into corresponding global variables and written into storage, but I find this a bit inconvenient. I figured I can make this more neat by using a structure variable called “weaponinfo” and make the other variables its child variables, but I can’t find a way to load the structure variable of an object into a global variable. I doubt if it is possible, but I still want to optimize this part of the code since picking up weapons will be frequent in my game.
Also, will the performance of the game drop if the storage is accessed frequently (almost once every second in the game) ? Will it be better to use global variables and only loading stuff when exiting or entering the game?