# Distance

> Get the minimum distance between this shape and the specified shape.

## Definition

* **Type:** Method
* **Namespace:** [Unity.U2D.Physics](/engine/6000.5/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule

## Distance(PhysicsShape, bool)

Get the minimum distance between this shape and the specified shape.

```csharp
public PhysicsQuery.DistanceResult Distance(PhysicsShape otherShape, bool useRadii = true)
```

### Parameters

**** (\[PhysicsShape]\(/engine/6000.5/script-reference/unity/u2d/physics/physicsshape)): The other shape to check the distance of.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to use the radii of both shapes or not.

### Returns

| Type                                                                                               | Description          |
| -------------------------------------------------------------------------------------------------- | -------------------- |
| [DistanceResult](/engine/6000.5/script-reference/unity/u2d/physics/physicsquery/distanceresult.md) | The distance result. |

## Distance(PhysicsShape, PhysicsTransform, bool)

Get the minimum distance between this shape and the specified shape.

```csharp
public PhysicsQuery.DistanceResult Distance(PhysicsShape otherShape, PhysicsTransform otherTransform, bool useRadii = true)
```

### Parameters

**** (\[PhysicsShape]\(/engine/6000.5/script-reference/unity/u2d/physics/physicsshape)): The other shape to check the distance of.**** (\[PhysicsTransform]\(/engine/6000.5/script-reference/unity/u2d/physics/physicstransform)): The transform used to specify where the other shape is positioned.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to use the radii of both shapes or not.

### Returns

| Type                                                                                               | Description          |
| -------------------------------------------------------------------------------------------------- | -------------------- |
| [DistanceResult](/engine/6000.5/script-reference/unity/u2d/physics/physicsquery/distanceresult.md) | The distance result. |

## Distance(ReadOnlySpan\<PhysicsShape>, bool)

Get the minimum distance between this shape and the specified shape(s) span.

```csharp
public PhysicsQuery.DistanceResult Distance(ReadOnlySpan<PhysicsShape> otherShapes, bool useRadii = true)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): A read-only span of the other shape to check the distance of.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to use the radii of both shapes or not.

### Returns

| Type                                                                                               | Description          |
| -------------------------------------------------------------------------------------------------- | -------------------- |
| [DistanceResult](/engine/6000.5/script-reference/unity/u2d/physics/physicsquery/distanceresult.md) | The distance result. |

## Distance(PhysicsBody, bool)

Get the minimum distance between this shape and all the shapes attached to the specified body.

```csharp
public PhysicsQuery.DistanceResult Distance(PhysicsBody physicsBody, bool useRadii = true)
```

### Parameters

**** (\[PhysicsBody]\(/engine/6000.5/script-reference/unity/u2d/physics/physicsbody)): The body whose attached shape(s) will be used to check the distance of.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to use the radii of all shapes or not.

### Returns

| Type                                                                                               | Description |
| -------------------------------------------------------------------------------------------------- | ----------- |
| [DistanceResult](/engine/6000.5/script-reference/unity/u2d/physics/physicsquery/distanceresult.md) |             |
