Android+Unity游戲開發之求物體間的距離代碼:
- using UnityEngine;
- using System.Collections;
- public class test : MonoBehaviour {
- public GameObject a;
- public GameObject b;
- public Vector3 m;
- public Vector3 n;
- void Start () {}
- void Update (){
-
- m=a.transform.position;
- n=b.transform.position;
- print(Vector3.Distance(m,n));
- }
- }