it will not work,
which you should have already found out by running it once?
I used SetTimer and ClearTimer to replace delay function in a C++ Function.
void MyFunction()
{
.....;
()->GetTimerManager().SetTimer(delayHandle,1.f,false,2.f);
()->GetTimerManager().ClearTimer(delayHandle);
......;
}
Will it work or not?
Not directly like that, in “SetTimer” you have to pass a method that will be called after the timer
the clear timer isn’t necessary
see here how to use timers : Gameplay Timers | Unreal Engine Documentation
No, thread will continue after calling SetTimer, C++ does any form of delaying code execution and your code runs on main UE4 thread, if you halt the code (for example by looping), it will freeze entire UE4. Delay node is usling the latent function system which is similar to timer system, but it won’t work the same way on C++.
You need to bind function to it which will be called when time pass on timer, you want to make it mroe compact you could use lambda (aka nested) function binded to FTimerDelegate
https://en.cppreference.com/w/cpp/language/lambda
Just palce this as set timer argument insted of function:
https://api.unrealengine.com/INT/API/Runtime/Core/Delegates/TBaseDelegate/CreateLambda/index.html
I just wonder if could Timer do the same thing as delay?