I basically need to split simple operations across time/several frames. I wouldn’t want to use new threads.
I couldn’t find any tutorial explaining how to do it.
Should I use Async Tasks? (The wiki has a tutorial updated up to 4.12)
Should I use timers?
Let’s say I want to interpolate an actor between two positions across time. Best generic and actor independent way to do it without reinventing the wheel?
I would be interested in an answer from someone more familiar, but I’ll say what I know.
I’ve seen timers commonly recommended in place of delays/waits. E.g. If I want something to happen after x seconds, set up a timer to call that function. You can also loop them.
Async tasks seem to be more for longer-term actions. I haven’t seen them used, though.
Since you’re dealing with time, you could create a timer that keeps calling your update function until it’s completed. You could also look into having the actor’s tick check if it needs to update the position.
Edit: While trying to solve another problem, I ran across the “Common Use Cases” on this Slate page which mentions timers being used for interpolation. Keep in mind this is UI instead of Actors, but it might point towards using a timer.
If you know where the actor is going and either the speed or the time required/left just use LERP. What’s the use case here? You might get a better answer. Just moving an object from A to B its pretty standard to use LERP.