Task Scheduler (C# / Unity)

Sometimes certain tasks don’t need to be updated every frame. For instance, if AI decision making is a time-consuming process, we could do it every 10 frames instead of every frame. Not only would this help alleviate the per-frame cost, but it would also provide an inherent reaction time for the AI, arguably making it behave more realistically. The TaskScheduler is a system for scheduling given objects for updates in this fashion, allowing you to define the update frequency explicitly. It also allows for defining how to space tasks in relation to each other, preventing tasks with similar frequencies from stacking up on the same frames.