#Does DOTS have an elegant way of running jobs every X amount of time has passed

1 messages · Page 1 of 1 (latest)

frozen nebula
#

I am currently using a system that has a if (currentTime > nextUpdateTime) { ... do job ... } situation going on. Which is not exactly super pretty but is the best way I can see of getting jobs to only run when needed.
Is there a built in solution that is more elegant (and potentially more efficient) for running jobs in intervals rather than per frame? If not is this a topic that Unity has mentioned or considered?

blazing storm
#

imo don't look for elegance, but pragmatism

To me this seems quite optimal, and easy to understand at first glance. Something somewhere has to check the condition, or the queue this job is in, anyway.

If you have a lot of things that run at intervals one could imagine making a list of jobs for a given frame, then iterate over the list for the current frame to fire off the jobs at the right time. This requires an abstraction of the data and the job function pointer, so this is probably not trivial (and there is overhead in that as well), and to me it seems more like a convenience improvement than a performance improvement.
Plus, then you need to manage the addition and removal of items to such a queue, because things usually don't last forever!

#

Another way to do this is to enable/disable the system(s) based on some condition(s). Which is probably also more expensive in reality.

frozen nebula
#

I see, thanks for the input. In that case I think I will stick to my original idea of having a dispatch system who's only job is tracking when and what jobs need dispatching each frame

mellow harness
#

You can have a system group with rate manager

#

Just like fixed step system group

blazing storm
# mellow harness You can have a system group with rate manager

I didn't think of that, that's definitely another way

I did think that when lanching a lot of jobs on intervals, you'd probably want to interleave them and not fire them at the same time, which would of course be doable with multiple rate managers if necessary

frozen nebula