Whats the best method to use for continually calling functions?
by Dennis Harrington · in Torque Game Builder · 05/01/2006 (2:17 pm) · 2 replies
I guess I'm just wondering what the most efficient method to use is. It seems odd that this isn't really explained anywhere, or maybe I'm just missing something.
So far, I'm using the onUpdateScene callback to trigger my functions that need to be called continously and I'm using Schedule for any timed operations that occur on the fly for short periods of time. Are these the two best methods to use? Are there any other methods/functions available for these types of operations?
My main concern with onUpdateScene is that it would put a heavy hit on the CPU. And my concern with using Schedule is that the time passed would not be consistent on different user's machines. Can anyone shed any light on these concerns?
Thanks in advance for any feedback.
Dennis
So far, I'm using the onUpdateScene callback to trigger my functions that need to be called continously and I'm using Schedule for any timed operations that occur on the fly for short periods of time. Are these the two best methods to use? Are there any other methods/functions available for these types of operations?
My main concern with onUpdateScene is that it would put a heavy hit on the CPU. And my concern with using Schedule is that the time passed would not be consistent on different user's machines. Can anyone shed any light on these concerns?
Thanks in advance for any feedback.
Dennis
#2
I had read the reference material about all of the methods but my main concern was from a best practices standpoint, I suppose. It sounds like schedule is the one I want for consistent and predictable calls.
Thanks again!
05/02/2006 (10:19 am)
Awesome. Thanks for the detailed breakdown, Jason. I had read the reference material about all of the methods but my main concern was from a best practices standpoint, I suppose. It sounds like schedule is the one I want for consistent and predictable calls.
Thanks again!
Torque Owner Jason Cahill
Default Studio Name
onSceneUpdate will be called once per rendered frame, which will vary by computer. Schedule will not run inconsistently. It is based on a time delta and gets called as close to that time delta as possible. setTimer is like schedule for consistent "heart beats" as well, but you only get one callback, whereas with schedule, you can have as many schedules running simultaneously as you like.