Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question RegisterPhysicsRuntimeSystemReadOnly clarifications

Discussion in 'Physics for ECS' started by argibaltzi, Aug 2, 2022.

  1. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    221
    Hi

    Can someone please explain how exactly this function works along with the write version?

    How is this meant to be used when you have input and output dependencies inside the physics system group?

    For example wait for the ExportPhysicsWorld to finish and before CopyPhysicsVelocityToSmoothing begins
     
  2. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    If you look into RegisterPhysicsRuntimeSystemReadOnly it is just a singleton query.
    So unity is just using the automatic dependency management.
    If your system needs to read or write physics it is handled the same way as dependency sorting when multiple systems need to read/write the same component.

    Using this...
    Code (CSharp):
    1. protected override void OnStartRunning()
    2.     {
    3.         this.RegisterPhysicsRuntimeSystemReadOnly();
    4.     }
    ...
    UpdateAfter(typeof(ExportPhysicsWorld))
    and
    UpdateBefore(typeof(CopyPhysicsVelocityToSmoothings))
    should work in your case
     
    argibaltzi likes this.