Search Unity

ComponentSystem: Is there something as OnFixedUpdate()?

Discussion in 'Entity Component System' started by Fallc, Jun 11, 2018.

  1. Fallc

    Fallc

    Joined:
    Mar 13, 2015
    Posts:
    48
    Hello my curious ECS friends!

    I'm currently porting over a script that relies on beeing called on FixedUpdate. Is there some attribute or similar that allows me to do so?
     
  2. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    If you put [UpdateBefore/After(typeof(FixedUpdate))] attribute on your system class it will be in a FixedUpdate step (but run before/after all other usual fixed updates) Requires `using UnityEngine.Experimental.PlayerLoop;`
     
  3. Fallc

    Fallc

    Joined:
    Mar 13, 2015
    Posts:
    48

    Yes, exacly what I was looking for! Many thanks!
     
  4. bjacksd

    bjacksd

    Joined:
    Jun 2, 2017
    Posts:
    3
    Ignoring invalid [UpdateBefore] dependency for EntitymoveSystem: UnityEngine.Experimental.PlayerLoop.FixedUpdate must be a member of the same ComponentSystemGroup.

    i have try using UnityEngine.Experimental.PlayerLoop
    and add the attribute
    and oh my i get this error @@ is it not working now or i did something wrong
     
  5. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    that's deprecated. now the systems are in an update hierarchy and they belong to a group.
    there exist 3 root groups: Initialization, Simulation, and Presentation.
    Simulation (the default) is meant to be updated in FixedUpdate. but it's currently not because of internal problems with it.
    as a workaround, you can create your group and manually update it in a MonoBehaviour.FixedUpdate. there is a sample for that in the samples repo
     
    bjacksd likes this.
  6. bjacksd

    bjacksd

    Joined:
    Jun 2, 2017
    Posts:
    3
    excuses me , may i have a link to the repo or give me some tips how to find that
     
  7. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Repo : https://github.com/Unity-Technologies/EntityComponentSystemSamples

    For update order docs + others there is an .md in the package folder you could read. And it is available online if you click on the documentation blue text on the UPM. For example the file you are looking for became this page online : https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/system_update_order.html

    *additionally I have wrote about this before, if you prefer longer paraphrase of that page : https://gametorrahod.com/world-system-groups-update-order-and-the-player-loop/
     
    bjacksd likes this.
  8. bjacksd

    bjacksd

    Joined:
    Jun 2, 2017
    Posts:
    3
    thank you!