how can we run task in one tick in unreal ?

Hello,

I am trying to run task in one tick so spamming input issue can be fixed
Wondering if there is any way to do it easily.
I was thinking to do something like
GetAsyncTaskManager()->AddToInQueue(Task)
or something like RunOnNextTick(task)

is there any other easier way to do this ?

Hello there @ROCKY.CHOI!

Checking with my peers, and through UE’s docs, the most simple method should be seting up a schedule using FTimerHandle

There are multiple ways to handle the operation, which would depend on what your project is trying to achieve. You can find more ideas in the following thread:

Oh thanks for your suggestion.
I guess I can use TTimerManager::SetTimer with the FTimerHandle to call specific function with numbers ?
Or I can use FTimerManager::SetTimerForNextTick

spamming what input? users pressing keys? sending data over the internet? The words you are looking for then is “rate limiting”.

Usually such “spam” happens not in one tick, but many. as people running a project with 60 frames per second play with 60 ticks per second.

the timer suggested previously can be your solution to that, ignoring or combining input after initial input for X time.

In blueprints, you could just use a delay node, since that creates an async task that is not interrupted or restarted when called.

// C++ Timer snippet, can get creative with the handle too:



FTimerHandle OutTimerHandle = FTimerHandle();
if (!bDelimiterActive) {
	bDelimiterActive = true;
	
	GetWorldTimerManager().SetTimer(OutTimerHandle, FTimerDelegate::CreateLambda([] () {
		// DoStuff()
		bDelimiterActive = false;
	})
	, MyDelay, false);
}