I’m trying to understand when and where to apply my checkpoint information in a typical singleplayer character death->load checkpoint situation.
I want to reset level state , but this could be any streamed area. I can serialize the relevant information just fine into my checkpoint, but it looks like I have to do a full server travel and world refresh to reset the state of the level.
The reset() function isn’t implemented on many Actors and has no calls on components.
I haven’t fully tested this in a package build, but the current full reload seems rather slow.
To restart the current game you can call ‘RestartGame’ from AGameMode. You can also just make a ServerTravel like:
GetWorld()->ServerTravel("?Restart", bAbsolute);
I would recommend you calling ‘RestartGame’ and if case you want to control when to restart the game you could override the ‘RestartGame’ in your own ‘AGameSession’ class.
Thanks for the reply, but I already have code to do that. My question was more about the most efficient and quickest way of “resetting” level content and then applying checkpoint information. The quickest in terms of development time is to do a server travel and apply the checkpoint info. It appears the quickest in terms of loading and setup time would be to reinitialize all actors that need it via their Reset() function, cleanup all transient/dynamic actors and then apply the info.
I’m doing this for online co-op so everything has to replicate correctly too. For now the server travel approach is what I’m going with to save dev time.
When applying checkpoint info do you do it before or after beginplay? In order for blueprint only actors to respond to saved property changes it looks like it needs to be pre-begin play and maybe after postinitproperties.
Do you deserialize all checkpoint info within RouteActorInitialize after preinitializecomponents? How is that handled with streaming?
My ideal world is I can load all actors, load my checkpoint info on top of actors that have it and then perform the rest of initialization.
If I need to do save fix-up in or around preinitializecomponents I don’t see an easy way of either doing it in a batch or finding the specific save info for each actor from the checkpoint information. Streaming may also complicate these things.
If I introduce online to this it adds another level of complexity. bleh.
It isn’t trivial in any case, if you spawn all actors, load your data and the apply it to your actors you need to wait to start the match until this has been finished and all is synced between clients, using replication or loading all data in all clients at once, this way you would not requite to wait for network initialization. That’s the way I did my last checkpoint system, spawning all actors and then initializing them in all clients at the same time. To make the game wait until you want to start it manually you can use the ‘bDelayedStart’ boolean flag in ‘AGameMode’.