OnUpdate vs. recursive schedule
by PeterB · in Torque Game Builder · 08/21/2007 (3:28 pm) · 6 replies
I assume using onUpdate is better practice than say:
But what if you really only need the function every 50 or 100 milliseconds? 200? Do you get less of a processing hit with a recursive schedule at 50 milliseconds than onUpdate for example?
Or maybe I'm wrong and a recursive schedule is just as good as onUpdate.
function myMainLoop()
{
// do stuff
schedule(33, 0, myMainLoop);But what if you really only need the function every 50 or 100 milliseconds? 200? Do you get less of a processing hit with a recursive schedule at 50 milliseconds than onUpdate for example?
Or maybe I'm wrong and a recursive schedule is just as good as onUpdate.
About the author
#2
Don't have hard evidence to back this up, but that's my feeling on it.
08/22/2007 (1:46 pm)
I always use recursive schedule for things that only need calls every 50 (or+) milliseconds. It just seems like the less you do EVERY frame (onUpdate) the better.Don't have hard evidence to back this up, but that's my feeling on it.
#3
onUpdate is called every 32ms, so if you dont need your function called that frequently, use something adjustable.
08/22/2007 (2:28 pm)
I agree with Spider, less is more.onUpdate is called every 32ms, so if you dont need your function called that frequently, use something adjustable.
#4
im pretty much up in the air on which saves more but i will give my own specific example, maybe someone can shine light down on me
ok lets say i have a bullet pattern(think modern-day shmup). and i have a projectile moving in the shape of a helix (sin wave) the only way to make the movement look smooth is to either use onUpdate(32ms) or schedule(32ms).... there both technically the same thing but is one better than the other for saving system memory?
08/26/2007 (1:10 am)
Hmmm, i do like this discussion though on which spares more system memory though...im pretty much up in the air on which saves more but i will give my own specific example, maybe someone can shine light down on me
ok lets say i have a bullet pattern(think modern-day shmup). and i have a projectile moving in the shape of a helix (sin wave) the only way to make the movement look smooth is to either use onUpdate(32ms) or schedule(32ms).... there both technically the same thing but is one better than the other for saving system memory?
#5
08/27/2007 (10:13 am)
Rendering actually happens faster than every tick I believe, so for it to move smoothly you would have to to this in a different way than just setposition every tick. Eg. paths.
#6
09/01/2007 (9:33 am)
There is also the setTimer() and onTimer() functions which can be used in place of recurring schedules.
Associate James Ford
Sickhead Games