Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question How to wait for colliders to be ready

Discussion in 'Physics for ECS' started by mvysinsky, Jan 24, 2021.

  1. mvysinsky


    Mar 26, 2017

    this is the result:

    No matter how long I wait before moving when I start a built game. I always fall through the first cube. After scene reloads, everything is fine. It is like physics is not properly initialised on first run (the cube has physics shape). Is there a way how to wait for it to be ready or detect when it is ready, please?

    This bug is not happening in the editor so it is hard to debug.
  2. Thygrrr


    Sep 23, 2013
    This may be related with a bug I see with the physics world not updating the static collision world correctly upon load.

    Try this: A few frames after loading, create or delete a static collider programmatically. (e.g. spawn a prefab instance, or destroy a specifically marked one, no need to faff with colliders themselves).

    That usually triggers the Static Body Change filter. I see this corruption when I add static bodies right in the first frame or so; and the collisionworld array then isn't big enough to hold all the colliders (or is never updated, not sure)
    jasons-novaleaf likes this.
  3. milos85miki


    Nov 29, 2019
    Hi @mvysinsky ,

    Could you please provide a bit more details:
    1. Did you ensure that all Entity creation and editing jobs are completed before BuildPhysicsWorld.onUpdate starts or after ExportPhysicsWorld's last job ends?
    2. How are you creating those cubes with PhysicsShape and are you changing them afterwards?
    3. Did you manage to debug a bit, does BuildPhysicsWorld properly detect those cubes as physics bodies?

    The problem Thygrrr found (thank you!) happens when you remove some component from a number of entities representing static bodies, so I'd like this to be investigated before concluding anything. A project with minimal repro scene would be useful, but answering my questions above might also lead us to the solution.