Version: 5.4
public static float Distance (Vector3 a, Vector3 b);

説明

ab の間の距離を返します

Vector3.Distance(a, b)(a-b).magnitude と同じです。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform other; void Example() { if (other) { float dist = Vector3.Distance(other.position, transform.position); print("Distance to other: " + dist); } } }