首页 > 技术文章 > 勾股定理 算距离

sy88 2013-11-29 19:47 原文

using UnityEngine;
using System.Collections;

public class Distance : MonoBehaviour {
    public GameObject _A;
    float _distance;
    // Use this for initialization
    void Start () {
        
    }
    
    // Update is called once per frame
    void Update () {
        _distance = Mathf.Sqrt(Mathf.Pow((_A.transform.position.x - transform.position.x), 2) + Mathf.Pow((_A.transform.position.z - transform.position.z), 2));
        Debug.Log("_distance=" + _distance);
    }
}

 

推荐阅读