Download

Serializing Delays into a SaveGame and restarting them with the same TimeRemaining when loading

Hi! I’ve asked this question in the Answers section, but got no answer, so I thought I’d ask it here, too. Hope that’s okay.

If there is no way, that seems like it would mean that you can’t use Delays in GamePlay-code and have that work with your SaveGames without modifying the engine.

Here’s the question: The class I want to serialize is
class FDelayAction : public FPendingLatentAction
{
public:
float TimeRemaining;
FName ExecutionFunction;
int32 OutputLink;
FWeakObjectPtr CallbackTarget;
//etc

FPendingLatentAction is

class ENGINE_API FPendingLatentAction
{
public:
//etc

As you can see, FPendingLatentAction does not derive from UObject, meaning that I can’t use UE4’s Cast to check if it is an FDelayAction. But in order to serialize all the FDelayActions, i would need to iterate through FPendingLatentActions and cast them to FDelayAction. dynamic_cast also wont work, because UE4 is compiled without RTTI.
I thought about somehow accessing the Node from the blueprint that made the FPendingLatentAction and seeing if that’s a Delay, but that data only exists within the FDelayAction.
I also considered using the GetDescription()-method and seeing if the returned string starts with “Delay”, but GetDescription() only exists in the editor. :wink:
If I can’t make this work, that would mean there’s no way to make Delays work with a SaveGame-system. I could change the engine code or turn on RTTI, but I’d much rather avoid making such changes to the engine.
Anyone see a way?

/////

On Answers: https://answers.unrealengine.com/que…estarting.html

You can implement your own latent function nodes, inheriting from UBlueprintAsyncActionBase.

Those are UObjects and you can add UProperties in them, from there you can serialize your persistent values.

so you mean making my own delay-nodes? would be rather unfortunate if that is really necessary, since everyone using the SaveGame-system would have to know not to use normal Delays and if anyone forgets, there would be no error message, just a silent bug. :frowning: