2点間の距離の取得方法を自分用にメモ。
[ 取得方法 ]
「Vecotr3.Distance()」で取得できます。
[ 使用例 ]
下記はVector3Test1とVector3Test2距離をコンソールに出力します。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScriptTest : MonoBehaviour { void Start() { Vector3 Vector3Test1 = new Vector3(20, 50, -60); Vector3 Vector3Test2 = new Vector3(-30, 90, 40); Debug.Log(Vector3.Distance(Vector3Test1, Vector3Test2)); } }