I have a simple conical mesh collider, and I’m trying to run a distance query using the code below.
var collider = Unity.Physics.MeshCollider.Create(vertices, triangles);
var physicsWorldSystem = Unity.Entities.World.DefaultGameObjectInjectionWorld.GetExistingSystem<Unity.Physics.Systems.BuildPhysicsWorld>();
var collisionWorld = physicsWorldSystem.PhysicsWorld.CollisionWorld;
var input = new ColliderDistanceInput
{
Collider = (Unity.Physics.Collider*)collider.GetUnsafePtr(),
MaxDistance = 0,
};
DistanceHit hit;
if (collisionWorld.CalculateDistance(input, out hit))
{
Debug.Log("Hit something: " + hit.Entity);
}
Doing that throws a NotImplementedError, because the input->Collider->CollisionType
is Composite
, and UnityPhysics.ColliderCollider
appears to only supports convex collisions.
The collider mesh is actually convex, but I don’t know how to convince UnityPhysics of this fact. Is there a way to make it interpret a MeshCollider as convex?