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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Question DOTS Physics fast moving objects collide before touching other objects.

Discussion in 'Physics for ECS' started by aducceschi, Jul 21, 2022.

  1. aducceschi

    aducceschi

    Joined:
    Feb 9, 2022
    Posts:
    31
    Hi,

    I have a ball and a surface that are both entities using the new DOTS Physics Package.

    When the ball moves fast (more or less the same speed as when you throw a ball with your hand),
    the ball collides with the surface around 20 cm (0.656168 ft) before touching the surface and bounces back.

    This only happens if it moves fast.

    Does anyone know how can I change this behaviour or at least reduce it?

    Thank you.

    EDIT: I have found a float called CollisionTolerance by doing this:
    World.DefaultGameObjectInjectionWorld.GetExistingSystem<BuildPhysicsWorld>().PhysicsWorld.CollisionWorld.CollisionTolerance;

    Unfortunately it says its read only and I can't reassign it. I tried to create a new Collision World and the replace the current world with the new one but to no avail. I can't even change the value on the new world. Any ideas?
     
    Last edited: Jul 21, 2022
  2. krooq

    krooq

    Joined:
    Jan 30, 2013
    Posts:
    175
    I think the way to do this in DOTS is to change the solver iteration count which of course affects the entire simulation, not just a single entity as the collision detection mode in gameobject based workflows would.

    You could try moving the entity to a location that ensures it will or wont collide during the simulation to account for this tolerance. Usually for fast moving objects one needs to do some manual fudgery.

    upload_2022-7-27_12-22-12.png
     
    aducceschi likes this.