Static Varible and testing multiplayer


I was testing changing the value of a static variable while testing the game in editor with multiple clients.

What i noticed was when the value of the static variable in 1 client changed, the variables for all the clients changes. Obviously, this wont happen if the clients and server are on different systems.

But does this mean that I launch 2 games one system, there will be only 1 static variable or this just happens inside the editor.

A static variable exists once per executable, since multi-player play in editor all executes within a single executable, the clients (and server) will share it. This will not happen if 2 separate stand alone clients are running on the machine.

In general I would not recommend the use of statics/singletons for gameplay concepts as it limits the usability of the multi-player play in editor functionality.