Where to store player specific, persistent variables in multiplayer environment?

Hey all,

Attempting a simple set-up where players can run around and pick up items in the map. If a player is killed, they re-spawn and retain all the items they’ve picked up.

My first attempt was to store these variables in the Player State, then, on re-spawn of a client, grab all the data from the Player State. Apparently Player State doesn’t work in a replicated environment. The cast to the Player State references a player index (default is 0) only the first player in the game gets saved data. So this system works perfectly for one player but no other players get data.

So my question is, how/where should I store player specific variables that survive a re-spawn in a replicated environment? Anyone have any thoughts/tutorials/videos that might help me out?

A new player state is created when a player enters the game (LogIn). It is a replicated variable, owned by a Player Controller (you can get the player controller reference by using Get Owner and casting to the controller).

You can grab all player states inside the Game State class from the “Player Array”. Once the player LogOut from the server, the player state is destroyed (afaik). You can store persistent information inside GameState, too. But try working with the Player Array to grab all the player states and save all of them in a for loop.

Don’t suppose you know of a tutorial or video that shows this?

You’ll have to forgive me, your explanation is a bit over my head. So are you saying that I SHOULD store player specific variables in Player State? I tried putting them in Game State and only the server would access it properly.

This one I think will help you.

I highly recommend you to take some time to watch all of his videos, since he explains a lot about replication.

The game mode set the rules for the game.

The game state set the states of the game, used to control events when the game has changed states.

The player state stores every information that must be replicated from a Player (User) to all other clients, or even player progress data, so far.

ah man, that’s money.

appreciate the link!

Haha, come back when you get something (Or not…)


good luck