UKismetSystemLibrary::Delay Usage

Hi! I am trying to use the Delay function just like I use in blueprints.

I am using FTimerhandlers with GetWorld()->GetTimerManager().SetTimer all the time but wanted to try this way.

I have this function in the same actor:

void ABookMenuCPP::CallLoader() { gamemode->myLoadTheGame(); }

then what I do is this:

	FLatentActionInfo action;
	accion.ExecutionFunction = "CallLoader";
	accion.CallbackTarget = this;
	UKismetSystemLibrary::Delay(this, 1.0f,action);

Is not working. I bet I am not defining the ExecutionFunction parameter as I should but I dont know.
Any Help :slight_smile:

Try making CallLoader UFUNCTION(BlueprintCallable)

1 Like

Hi! and thanks for your reply but what I was trying to do Is using the UKismetSystemLibrary::Delay in C++ just like we do in blueprints

Don’t use this is C++, use a Timer, via GetWorld()->GetTimerManager. You can not delay functions in c++ but you can do stuff after a set time expired, again using TimerManager.

1 Like

Hi! yes I usually use Timers exactly as you say but I was curious because UKismetSystemLibrary::Delay is an available library C++ function and I just wondered about the chance of use it in C++


I’m not saying call it in BP, but it’ll need UFUNCTION markup to make the callback work. You can’t call an arbitrary C++ function with the name of the function alone. Blueprint does call functions by name, and that’s why the FLatentActionInfo takes an FName. To make Unreal aware of your function (and make it callable by name), it needs UFUNCTION markup, and it might additionally need to be marked as BlueprintCallable.

Looked it up and you may need to additionally set accion.UUID = 0; and accion.Linkage = 0;. If you’re setting multiple timers, UUID needs to be unique for each one within the same object (e.g. for the same actor). So if you’re setting multiple timers you’d probably want an int32 TimerUUID = 0; var in the class then do accion.UUID = TimerUUID++;. I think Linkage can always be zero for C++ function callbacks.

1 Like

Thanks! I will give it a try!! anyway it was just my curiosity exploring bult in functions :slight_smile: :slight_smile: :slight_smile: