Delay blueprint node in C++?

Hello guys.

I made a little game some time ago using Blueprints and I’d like to transform everything in C++.

I need to know how to build a Delay function in C++, the equivalent of this:

I read something about making a separate thread for that…
Any help?

As far as I know:


static void Delay(float TimeSeconds, UWorld* World)
{
    float EndTime = World->TimeSeconds + TimeSeconds;
    for (; World->TimeSeconds < EndTime;);
    return;
}

And call it like this:



// code
TheFunctionsClass::Delay([float delay], GetWorld());
// this will execute after delay
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, "Delay passed!");

Hope this helps :smiley:

This doesn’t work properly.

The object, once picked up, doesn’t disappear and consequently won’t appear after X seconds. (respawn system)

I think the best way is to use a timer.

I’m afraid you won’t be able to pause code execution. That isn’t actually what the blueprint does, it will just wait for a certain time to pass before the next node gets to execute. You can do that in C++ with a timer, like Raikoh says.

Solved using a timer =)