Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

System that gets updated at fixed intervals

Discussion in 'Entity Component System' started by Allan-Smith, Jul 28, 2018.

  1. Allan-Smith

    Allan-Smith

    Joined:
    Feb 7, 2012
    Posts:
    57
    Hi,

    Is there a way currently, or plans, to add implementations of ComponentSystem, JobComponentSystems... that get updated only once every X interval of time? Be it every 10 frames, or every 1 second or what not, I can see this being extremely helpful in some cases and I know this can be achieved by caching something like "next time to update" and when the system gets called check if that time is now or not, but if the system wasn't even called in the first place, that would be even better.

    Best,
    Allan
     
    PalmGroveSoftware and ChrisPie like this.
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,594
  3. Allan-Smith

    Allan-Smith

    Joined:
    Feb 7, 2012
    Posts:
    57
    Hm thats not really what I was suggesting... should be something doable on a pure ECS way, and while it is trivial to have timekeeping myself, by storing next time to update or next frame to update on components, I just think it would be awesome to have a ThrottledComponentSystem, ThrottledJobComponentSystem or something like that, where the "Throttling" came from above.

    Anyway, thanks for the reply!
     
  4. Mr-Mechanical

    Mr-Mechanical

    Joined:
    May 31, 2015
    Posts:
    507
    This is a very good post that is also relevant to my project. The only way I know of is using the attribute [UpdateAfter(typeof(UnityEngine.Experimental.PlayerLoop.FixedUpdate))] (you can change frequency in the Unity Editor). It would be very nice to have custom loops in pure ECS that don't rely on built-in stages of the PlayerLoop (for more customized behavior).
     
  5. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,594
    Indeed good topic, since I will need it as well.
    But I don't mind using timers, as long their are only in one place, to drive rest of the scripts.