Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question [DOTS] Understanding the ConveyorBelt script in the physics samples

Discussion in 'Physics Previews' started by Steffen-ttc, Nov 14, 2022.

  1. Steffen-ttc


    May 27, 2017
    Hi everyone,

    It's my first time with dots / ecs and I have some difficulties understanding some lines in the conveyorbelt sample.

    I'm talking about this script: GitHub - EntityComponentSystemSamples

    The corresponding scene is "5f. Change Surface Velocity" in the "5. Modify" folder.

    Currently, my main questions are:
    1. Why using a ComponentLookup<ConveyorBelt in PrepareConveyorBeltSystem and why checking against EntityA || EntityB? If I comment out line 135, it seems to be working fine. In the manual (Manual: Overriding intermediate simulation results) there is exactly this sample without using this check.
    2. According to the manual, we should use SystemAPI.GetSingletonRW instead of GetSingleton. But the physics sample is using the read-only SimulationSingleton for both systems. Why is it still working, although we are writing the JacobianFlags and the SurfaceVelocity?
    3. The ConveyorBeltSystem distinguishes between jacHeader.EntityA and jacHeader.EntityB to calculate the velocity which will be added to the jacHeader.SurfaceVelocity. I assume this is just for the offset calculation of the angular belt. If I have just linear belts, I could fully remove the ComponentLookup<ConveyorBelt>. Is this correct?
    Thank you very much,
    goncalo-vasconcelos likes this.