Using a delay in C++

poplockentaco
Thu, 26 Jan 2017 21:10:50 +0000
Blueprint

Hi everyone! I’m trying to use the Delay function in the KismetSystemLibrary but it doesn’t seem to work despite me providing all the proper functions parameters. Has anyone been able to get this to work? I’d rather not have to create separate timers for it since there’s obviously a function already made for delays.

Code
.cpp

// Along with other includes
#include "Kismet/KismetSystemLibrary.h"

// Various code

void AMyActor::BeginPlay()
{
     Super::BeginPlay();
     FLatentActionInfo LatentInfo;
     UKismetSystemLibrary::Delay(this, 3.0f, LatentInfo);
     UKismetSystemLibrary::PrintString(this, FString("After Delay"));
}

The Delay function takes a world context, a float duration, and a latent action info struct.
Doing this exact same thing in blueprints works, but here, the PrintString function fires immediately.

5 posts - 5 participants