Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

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:
    598
    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
     
    filod likes this.