- I have a point in the world
- I have a collider
- I’d like to know the distance from point to collider (especially the negative distance if there is penetration)
I’m trying to do this like so:
ConvexCollider* convexCollider = (ConvexCollider*)physicsCollider.ColliderPtr;
PointDistanceInput pointDistanceInput = new PointDistanceInput
{
Filter = convexCollider->Filter,
MaxDistance = 0f,
Position = myWorldSpacePoint,
};
convexCollider->CalculateDistance(pointDistanceInput, out DistanceHit pointDistanceHit);
But I always get a distance of zero. What am I doing wrong?
- Is my cast to ConvexCollider valid? (“physicsCollider” here is a capsule primitive collider, of type “PhysicsCollider”)
- Is my “Position” assignment in PointDistanceInput valid? Should it be in worldSpace?