Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Distance

Calculates the distance between two vectors.
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

Distance(Vector2Int, Vector2Int)

Calculates the distance between two vectors.
public static float Distance(Vector2Int a, Vector2Int b)

Parameters

The first vector to check.

The second vector to check.

Returns

Type

Description

floatThe distance between
a
and
b
.

Remarks

Vector2.Distance(a,b)
is the same as
(a-b).magnitude
.

Distance(Vector2Int, Vector2Int)

Calculates the distance between two vectors.
public static float Distance(in Vector2Int a, in Vector2Int b)

Parameters

The first vector to check.

The second vector to check.

Returns

Type

Description

floatThe distance between
a
and
b
.

Remarks

Vector2.Distance(a,b)
is the same as
(a-b).magnitude
.