Distance
Get the minimum distance between this shape and the specified shape.
Read time 1 minuteLast updated 11 days ago
Definition
- Type: Method
- Namespace: Unity.U2D.Physics
- Assembly: UnityEngine.PhysicsCore2DModule
Distance(PhysicsShape, bool)
Get the minimum distance between this shape and the specified shape.
public PhysicsQuery.DistanceResult Distance(PhysicsShape otherShape, bool useRadii = true)
Parameters
The other shape to check the distance of.
Whether to use the radii of both shapes or not.
Returns
Type | Description |
|---|---|
| DistanceResult | The distance result. |
Distance(PhysicsShape, PhysicsTransform, bool)
Get the minimum distance between this shape and the specified shape.
public PhysicsQuery.DistanceResult Distance(PhysicsShape otherShape, PhysicsTransform otherTransform, bool useRadii = true)
Parameters
The other shape to check the distance of.
The transform used to specify where the other shape is positioned.
Whether to use the radii of both shapes or not.
Returns
Type | Description |
|---|---|
| DistanceResult | The distance result. |
Distance(ReadOnlySpan<PhysicsShape>, bool)
Get the minimum distance between this shape and the specified shape(s) span.
public PhysicsQuery.DistanceResult Distance(ReadOnlySpan<PhysicsShape> otherShapes, bool useRadii = true)
Parameters
A read-only span of the other shape to check the distance of.
Whether to use the radii of both shapes or not.
Returns
Type | Description |
|---|---|
| DistanceResult | The distance result. |
Distance(PhysicsBody, bool)
Get the minimum distance between this shape and all the shapes attached to the specified body.
public PhysicsQuery.DistanceResult Distance(PhysicsBody physicsBody, bool useRadii = true)
Parameters
The body whose attached shape(s) will be used to check the distance of.
Whether to use the radii of all shapes or not.
Returns
Type | Description |
|---|---|
| DistanceResult |