Best way to loop a function?

What’t the most efficient way to loop a function every frame while I needed it? Would using the “set timer by event or function name” on loop be the best? Or would using an event track timeline to loop a function work better and be more performant? Event tick is out of the question. Any pointers?

“What’t the most efficient way to loop a function every frame while I needed it”

Only tick can do that, the rest is time based and you have no guaranty it will run on each frame. Also timers as i know runs game thread same as tick so it will effect performance either way. You could try making your own thread, but thats C++ only.

Most efficient way to loop on each frame is to use Tick efficiently (do stuff only if it’s needed) and if you can code it in C++. And you don’t need to be scared of Tick, it a event that drives entire game and set actors in motion, all you need to do is to fit in 16ms for 60FPS, you can check “Blueprint Time” and tick times in “stat game” command and profiler (Window->Devloper Tools->Session Frontend). Also tick is multithreaded, each tick group is executed in max 8 threads and each tick of actor of a single group are queued evenly in all threads (atleast thats what i seen in code, i dont know if this is enabled by default i seen single thread mode there too), so if you put that in account tick is more efficient then other interval events… it needs to be as it drives your game

If you want feather help explain what exacly you want to do, each case is different.

1 Like