Hey, I’m generating some mesh colliders for terrain in ECS with MeshCollider.Create(MeshDataArray, CollisionFilter, Material).
I need to perform some collider casts against it, but they refuse to work entirely - which is why my character just falls through it.
On the other hand, “normal” raycasts and rigidbodies work without problems.
The PhysicsDebugDisplay also shows them correctly.
Also, when I switch to Havok, nothing collides with the terrain anymore
.
Do I need to perform some special setup for collider casts to work? Or do I need to assign the colliders in a specific group? Currently, I’m just adding a PhysicsCollider, PhysicsWorldIndex and LocalTransform to the terrain entities and set them up in SimulationSystemGroup.
I’ll also attach some screenshots with the component values and scene view.
I’m running out of ideas, so thanks for your help. ![]()
For reference, that’s the system I’m testing the collider casts in the screenshot with:
partial struct RaycastTestSystem : ISystem
{
void ISystem.OnCreate(ref SystemState state)
{
state.RequireForUpdate<PhysicsWorldSingleton>();
}
void ISystem.OnUpdate(ref SystemState state)
{
new RaycastTestJob()
{
physicsWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>()
}.ScheduleParallel();
}
[WithAll(typeof(RaycastTestTag))]
partial struct RaycastTestJob : IJobEntity
{
[ReadOnly] public PhysicsWorldSingleton physicsWorld;
public void Execute(in RaycastTestTag position, in LocalTransform transform, in PhysicsCollider collider)
{
ColliderCastInput input = new ColliderCastInput(
collider.Value,
transform.Position + (math.down() * 4), //Offset so the entity doesn't collide with itself
transform.Position + (math.down() * 20));
Debug.Log(physicsWorld.CollisionWorld.CastCollider(input, out ColliderCastHit closestHit));
}
}
}


