Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

otherShape

The other shape to check the distance of.

useRadii

Whether to use the radii of both shapes or not.

Returns

Type

Description

DistanceResultThe 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

otherShape

The other shape to check the distance of.

otherTransform

The transform used to specify where the other shape is positioned.

useRadii

Whether to use the radii of both shapes or not.

Returns

Type

Description

DistanceResultThe 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.

useRadii

Whether to use the radii of both shapes or not.

Returns

Type

Description

DistanceResultThe 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

physicsBody

The body whose attached shape(s) will be used to check the distance of.

useRadii

Whether to use the radii of all shapes or not.

Returns

Type

Description

DistanceResult