Unity.Physics.Collider.CastRay not working?

A BoxCollider at origin with size 1.0 and identity rotation is not hit by a ray going through the origin from 0,10,0 to 0,-10,0.

Is this a bug - or am I simply missing something because I am already blind to it?

using var testCollider = BoxCollider.Create(new BoxGeometry
{
    Center = float3.zero,
    BevelRadius = 0f,
    Orientation = quaternion.identity,
    Size        = new float3(1f, 1f, 1f)
});

if (testCollider.Value.CastRay(new RaycastInput
    {
        Start = new float3(0f, 10f, 0f),
        End   = new float3(0f, -10f, 0f)
    }))
{
    this.LogDebug("Hit");
}
else
{
    this.LogDebug("Is this a bug?"); // <- CastRay returns false
}

Using these versions

"com.unity.physics": "0.5.1-preview.2",
"com.unity.entities": "0.17.0-preview.42",
"com.unity.mathematics": "1.2.5",

You haven’t specified a CollisionFilter

1 Like

@tertle You are correct. I assumed, the default is CollisionFilter.Default, but the default sadly is CollisionFilter.Zero.

1 Like