How to make PlayerController persist when joining a server?
Here's my situation:
I have a main menu in which I can set a player name. From this menu, I can join an online game. I want my name set in the offline menu to persist to the online session. I am using this to travel to the server:
Here's what I tried:
I don't really know what to try next. I can think of some disgusting hacky solutions, but I'd much rather understand how to do things properly
I don't why you trying to more entire classes to server insted of just setting player name on PlayerController start up. PlayerController is not persistent not in client or server.
No sure if this gonna work with replication right but try using config, it will also handle storage for you. Mark your property to be config savable UPROPERTY(config) and then call SaveConfig() in that object.
I think argument are actually optional as i seen in engine code this function used without anything. This will store config of class in to ini file (in case of player controller it is set to store in Game.ini) and if i'm not mistaken it will automatically restore once PlayerController is spawn in client, if not you can do LoadConfig() on init
MAke sure htat this property replicates from client to server somehow, on server side you could set it to PlayerState, then it should work i think
Note that you can do this in any UObject so this is useful for all kind of things ;]
answered Jun 07 '16 at 09:46 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here