Exemplo n.º 1
0
 // Distance between two ClosestPointOnBounds
 // this is needed in cases where entites are really big. in those cases,
 // we can't just move to entity.transform.position, because it will be
 // unreachable. instead we have to go the closest point on the boundary.
 //
 // Vector2.Distance(a.transform.position, b.transform.position):
 //    _____        _____
 //   |     |      |     |
 //   |  x==|======|==x  |
 //   |_____|      |_____|
 //
 //
 // Utils.ClosestDistance(a.collider, b.collider):
 //    _____        _____
 //   |     |      |     |
 //   |     |x====x|     |
 //   |_____|      |_____|
 //
 public static float ClosestDistance(Collider2D a, Collider2D b)
 {
     return(Vector2.Distance(a.ClosestPointOnBounds(b.transform.position),
                             b.ClosestPointOnBounds(a.transform.position)));
 }