勾股定理 算距离

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);
    }
}

 

posted @ 2013-11-29 19:47  古刹红罗  阅读(237)  评论(0编辑  收藏  举报