Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Vector3.Distance

マニュアルに切り替える
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); } } }