Khao
Member
Okay, so. I'm making a multiplayer game where each player can create their own profile to save their own control configurations, and keep track of their own stats and whatnot. Think Smash Bros, you create your profile by inputting a name, and everything you do while using that profile is stored into that specific profile so the game remebers your personal preferences and achievements. You can change or create profiles at any time, and up to 4 of them can be used at once (because there's 4 players in the game).
I'm still adding features to these profiles, but between controls, statistics, character customization, gameplay settings and other minor features, I'm already looking at something like 200 variables per profile. As you probably already guessed, I'm storing all of that data as global variables.
Invite your friends over. Have multiple profiles for different game modes or just to screw around with the customization. Before you notice, you're gonna have, let's say, 30 profiles saved in your game. With my current system... that's around 6000 global variables. And that's assuming you don't create more profiles, which is perfectly possible. Create 100 profiles (my current maximum) and the game is now tracking 20,000 global variables!
Now, worth to have in mind. All of those variables are not being constantly checked. You load up your profile and the game checks a bunch of the profile values to assign them to the active player, but otherwise? The game mostly just checks for player names to draw them on the UI.
But with all that in mind...
Is this... you know... bad for the game?
Performance? Memory? Are there any drawbacks to using such a humongous amount of variables? Right now the game works perfectly fine enough, but I haven't really tested it on older PCs, so it's hard to tell for sure. Should I worry about it?
I'm asking because it's not too late to go back. Just now, I'm starting to actually code a proper saving system, and it's the perfect opportunity to go back and delete all those global variables, while making it so the game only loads variables as needed. It's a lot of extra work, but if this can potentially become an issue, I'm more than up for it.
However, if the impact on performance is like... insignificant, I'm not going to bother. Especially since I feel like it's easier to work with the global variables than having to save and load constantly whenever I want to access them. But again, if performance can be affected, then it's a must.
So yeah, anyone had any experience dealing with thousands of global variables, or know of any potential side-effects? I've tried to google an answer and responses are kind of... mixed.
I'm still adding features to these profiles, but between controls, statistics, character customization, gameplay settings and other minor features, I'm already looking at something like 200 variables per profile. As you probably already guessed, I'm storing all of that data as global variables.
Invite your friends over. Have multiple profiles for different game modes or just to screw around with the customization. Before you notice, you're gonna have, let's say, 30 profiles saved in your game. With my current system... that's around 6000 global variables. And that's assuming you don't create more profiles, which is perfectly possible. Create 100 profiles (my current maximum) and the game is now tracking 20,000 global variables!
Now, worth to have in mind. All of those variables are not being constantly checked. You load up your profile and the game checks a bunch of the profile values to assign them to the active player, but otherwise? The game mostly just checks for player names to draw them on the UI.
But with all that in mind...
Is this... you know... bad for the game?
Performance? Memory? Are there any drawbacks to using such a humongous amount of variables? Right now the game works perfectly fine enough, but I haven't really tested it on older PCs, so it's hard to tell for sure. Should I worry about it?
I'm asking because it's not too late to go back. Just now, I'm starting to actually code a proper saving system, and it's the perfect opportunity to go back and delete all those global variables, while making it so the game only loads variables as needed. It's a lot of extra work, but if this can potentially become an issue, I'm more than up for it.
However, if the impact on performance is like... insignificant, I'm not going to bother. Especially since I feel like it's easier to work with the global variables than having to save and load constantly whenever I want to access them. But again, if performance can be affected, then it's a must.
So yeah, anyone had any experience dealing with thousands of global variables, or know of any potential side-effects? I've tried to google an answer and responses are kind of... mixed.
Last edited: