don't use collider's transform position when checking for distance

This commit is contained in:
in0finite 2020-06-28 23:56:20 +02:00
parent 7da990e105
commit b8051fe2d9

View file

@ -81,13 +81,10 @@ namespace SanAndreasUnity.Utilities
{
Vector3 closestPointOnCollider = collider.ClosestPointOrBoundsCenter(center);
float distanceToPointOnCollider = Vector3.Distance(center, closestPointOnCollider);
float distanceToColliderTransform = Vector3.Distance(center, collider.transform.position);
float minDistance = Mathf.Min(distanceToPointOnCollider, distanceToColliderTransform);
if (minDistance < closestPointDistance)
if (distanceToPointOnCollider < closestPointDistance)
{
closestPointDistance = minDistance;
closestPointDistance = distanceToPointOnCollider;
closestPointCollider = collider;
}