Hey KillerPenguin!
If it helps there’s an alternative method.
You could create your own UObject that gets used like an if statement.
So you could do something like:
bool CustomClass::CustomTimer(float & Time)
{
if(Time > 0)
{
Time -= 0.01f; //Run down in seconds.
return false;
}
else
{
Time = 0;
return true;
}
}
Then because you are using an outer parameter, you can quickly set up a UPROPERTY float.
And you’ll still be able to handle your function with normal parameters like so:
if(CustomTimer(TimeIWantToUse))
{
MyFunction(MyParam1, MyParam2, etc);
}
I haven’t tested the above, since it’s just off the top of my head, but you shouldn’t have any issues.
I know it’s not the most elegant of solutions, but at least it gets the job down.
You could objectify it, so you don’t need to hold a float property, and make it so the object self deletes at the end.
The other option is to place the timer function in a custom static library.
Your final alternative is to look into Threads, which is covered in detail by Rama **HERE
**Considering Coroutines where developed to be Memory-safe alternatives to threads,
it should have most of the functionality you are after! :3
Hope this helps!
-