Wait A Frame

Hello guys,

I spawn some actors and after that i want to find them. But, I need to wait a frame inorder to find those actors…
So, my question is how can I wait a frame in Unreal Engine 4 without using the Tick function…??

Thanks in advance!

In BP you can use a delay set to 0s. In C++, you can use a timer instead.

It would be really helpful if you write the code of it because i am kinda confused with the SetTimer…

Something like this:

In .h file:

bool HasWaited = false;

In .cpp file:

void BeginPlay()
{
	Super::BeginPlay();
	
	if (!HasWaited)
	{
		FTimerHandle timerhandler;
		GetWorld()->GetTimerManager().SetTimer(timerhandler, [this]() {HasWaited = true; BeginPlay();}, 0.0f, false);
     }
     else
     {
		...
     }
}

With 0.0f it doesnt work for me and i cant find the objects that i want. But if i put 0.001f it works just fine!! Thanks you so much :slight_smile:

Even simpler. Thanks.

There’s also the function SetTimerForNextTick or something similar on the timer Manager.

3 Likes