Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Distance between two colliders

Discussion in 'Physics for ECS' started by Inter-Illusion, May 27, 2021.

  1. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    587
    I see that there is
    World.CalculateDistance to find the distance between a collider and the (closest / all) colliders in the world.
    But, is there a way to find the distance between two specific colliders given their transforms?

    Similar to Physics.ComputePenetration() or Collider.ClosestPoint ?
     
  2. MaxAbernethy

    MaxAbernethy

    Joined:
    Mar 16, 2019
    Posts:
    53
    Collider.CalculateDistance
    For example if you have colliderA, colliderB with transformA, transformB respectively, then you can call colliderA.CalculateDistance with ColliderDistanceInput.Collider = colliderB and ColliderDistanceInput.Transform = transformA^-1 * transformB