Check space when instantiating

It seems like unless you want to write your own logic for storing/querying AABB overlaps, the key to this would be finding a way to update a PhysicsWorld within a job. Basically, a collider only becomes detectable by physics queries after the CollisionWorld has updated its Broadphase, so that’s why even if you instantiated all your entities directly on the main thread without deferring entity spawn, checking overlaps still wouldn’t work

I’ve never tried this, but I see that there is such a thing as CollisionWorld.BuildBroadPhase()

So if you can figure out how to:

  • Spawn something
  • Manually add that thing’s rigidbody to the PhysicsWorld somehow (not sure how to do that yet)
  • Call CollisionWorld.BuildBroadPhase()
  • Now you can do the AABB test

In theory, that might work. But I’m very very uncertain. I also suspect that calling BuildBroadPhase() at every iteration would be too heavy, and we might need some form of incremental BuildBroadPhase() instead. I suspect classic Unity physics must’ve done something like that (?)


I think it would be really useful to have options to solve that problem, because I encountered a similar situation in this project . If two bullets are about to hit the same zombie in the same frame, what I’d want is that the first bullet destroys the zombie, and the other one goes right through (doesn’t detect any raycast hit). But since I had no way to instantly remove the hit zombie’s collider from the CollisionWorld and re-update the broadphase within a job, I couldn’t achieve what I wanted