[PLUGIN] Savior

This construction won’t work, single- or multiplayer. Can you please advise, maybe there’s something I’m missing here? Save returns success, but load after ServerTravel is failing

Add a SGUID Guid structure to your actor class.
Generate a unique persistent value in editor (no need to use the ‘Generate’ nodes)…

Then use this instead:
https://brunoxavierleite.github.io/S…rWithGUID.html

Thanks, that worked. Now the procedure returns success, but actual variables are not loaded (they are marked for SaveGame and Savior serializable interface is implemented). Is there something else I should do after loading?

Then there’s no save data of the object in file.
I don’t know if you should use event “Destroyed” for that.

You can open the save file on a notepad and see if there’s any record of the guid in there as a string.
And you also have to make sure you are saving the data on server, you could be saving actor on client but there’s nothing there to be saved…

Thanks for the tip, I’ve modified the saving procedure and now it saves 2 players’ states properly and variables are in the savegame file. But loading still not happening even when I do it server side (in game mode on BeginPlay for both players, I’ve attached the setup). Can you please advise?

UPD: this setup works for singleplayer though

Guid must be unique for APlayerState Actor you have for each player… I don’t know if you are assigning a Guid for player 1 and another for player 2.

That must be done on server upon spawn.
And the guid value you choose to use for each have to be constant.

Yes, but no matter whether I use the GenerateOnce Savior node for this or set it manually the loading just won’t happen. Maybe I should call it from within the player state itself? Also the issue is that I need to load the state on the server from the client when this client joins, but this player can also play offline and his progress must be carried to the co-op session

Hmm in that case I don’t know if you should do that on server at all then.

If everything can be changed in single player mode I would save on client only and do the inverse path: through a RPC send data from client to server when that player join the server. PlayerState in that case won’t help.

Just treat everything as a single player save file, then send player data to server. Unfortunately there’s no built-in solution in the plug-in for that.

Yeah, that is something I will try to manage outside of the plugin, maybe figure out a solution to store unlocks in a table somehow. I need to store unlocks for gear per player and that is the only point that the player can bring to server when connecting. Other stuff like pickups and currencies are destroyed on death so I planned to store them in PlayerState so the connected player will have PlayerSate in mint condition when connecting. The only point I need to save it is when the party travels between levels and that is what I’m trying to do here

But so far I can’t get it to load after ServerTravel no matter what I try

One more question - what is the difference between Saviors interfaces Serializable and Procedural? I mean the core difference in usage

the Procedural interface tells the plugin that the class expects to be respawned at runtime by the plugin and it is waiting for slot data to be passed in to that actor once it has been respawned from Guid…

  1. The plugin will check if that Class + Guid already exists in level, if so then it passes the load data to the class to use with Load Actor : (Slot Data)
  2. If the result is that the current Class + Guid is still missing on level, then it will first tell the Game Thread to spawn an Actor of that Class, assign the missing Guid to it then go back to step 1.

Thanks for the info. By any chance is there a way to set PlayerState to be persistent throughout the entire session?

It is an Actor, so when moving to another level you should try things such as “Seamless Travel” functions.
You can find PlayerState API here… take a look at functions that talk about “copy” properties:

https://docs.unrealengine.com/en-US/…ate/index.html

Thanks, I’ve seen it, but I’m a “BP only guys” so unfortunately, I can’t get much use of it. I already use seamless travel together with ServerTravel to change map, but PlayerState always gets dropped and respawned. Some folks whisper about the mysterious Persistent Actor List (or something like that). Is it something that can be reached via BP’s, maybe?

I’ve never heard of any persistent actor list, sorry. The map will always spawn new actors when you replace persistent level.

Hm, I see. But what is the common flow for dragging data along through the levels in multiplayer? I mean the player specific data in co-op, not something that you can write in game instance. (pardon for sliding off topic from Savior a bit).

Also I can’t quite get the mechanism of GUID generation - Savior’s node Create Once is generating a new GUID for PlayerState every time I start the game and that’s why loading fails I guess. Is that intended?

This is why I told you to not use the generator node… It’s not intended to be used in case like this.
You need to manually generate a persistent guid value instead.

And PlayerState has CopyProperties() and ReceiveCopyProperties() functions
https://docs.unrealengine.com/en-US/…ies/index.html
https://docs.unrealengine.com/en-US/…ies/index.html

Yeah, that’s a bummer - I still need to generate a persistent GUID, but now I gotta figure out how to make it unique for each client’s install

As for the CopyProperties - thanks for pointing it out, but so far I have no idea how to implement them, neither it’s available in my PS blueprint (even though it should be from that link). Well, I guess I’ll go bang my head against the wall a bit more

What you’re trying to do should be tied to a player account and you should use something like Epic’s Online Services.

Yep, I’ve already thought that I’ll need an external identification at some point to be able to tie all the stuff to a common profile.
Also CopyProperties override does not get called in multiplayer for some reason, only in single-player (in BP at least)