Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Android+Unity游戏开发之求物体间的距离

Android+Unity游戏开发之求物体间的距离代码:
  1. using UnityEngine;  
  2. using System.Collections;  
  3. public class test : MonoBehaviour {  
  4.     public GameObject a;  
  5.     public GameObject b;  
  6.     public Vector3 m;  
  7.     public Vector3 n;  
  8.     void Start () {}      
  9.     void Update (){    
  10.           
  11.      m=a.transform.position;    
  12.      n=b.transform.position;    
  13.      print(Vector3.Distance(m,n));    
  14.    }   
  15. }