Best Practice For Player Stats Data

Hi

Currently i have put all the stats data which contains more than 10 long variable in one Class with name PlayerStats which is a Singleton, but i found little lag in game scene , Is there any Best Practice to maintain Player Stats.

Thanks in Advance!

“10 variables” shouldn’t cause lag. I assume they aren’t textures you modify pixels of each frame, to put it into perspective.

Use the profiler to figure out what the bottleneck in your game is.

There are lots of approaches of accessing PlayerStats. Pick one that makes sense for you and that doesn’t get in the way of developing your game. Maybe a singleton is what you want. If you find problems with using a singleton, adapt and create a new mechanism as needed.