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. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    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

    Steffen-ttc

    Joined:
    May 27, 2017
    Posts:
    12
    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,
    Steffen
     
    goncalo-vasconcelos likes this.