How to make Unity DOTS Physics Ray cast works with ECS?

2.6k views Asked by At

The problem: I have 3 game objects, that have PhysicShape and PhysicBody(static) components. I convert it into entities and move on to the scene. I don't the objects will collide with each other, so I try to make Ray cast to handle another object before they will collide. But seems I did something wrong and Ray cast doesn't "see" other objects (they all on one layer and all are entities).

My Ray cast code

var input = new RaycastInput() {
  Start = translationVal,
  End = translationVal + localToWorld[i].Forward * 2f,
                    
  Filter = new CollisionFilter {
    BelongsTo = ~0u,
    CollidesWith = ~0u, // all 1s, so all layers, collide with everything
    GroupIndex = 0
  }
};
                
if (CollisionWorld.CastRay(input, out var hit)) return;  //always false :(
0

There are 0 answers