Vector3.Distance

来源:互联网 发布:协同工作软件 编辑:程序博客网 时间:2024/06/05 09:53

Returns the distance between a and b.

Vector3.Distance(a,b) is the same as (a-b).magnitude.

using UnityEngine;using System.Collections;public class ExampleClass : MonoBehaviour {    public Transform other;    void Example() {        if (other) {            float dist = Vector3.Distance(other.position, transform.position);            print("Distance to other: " + dist);        }    }}
原创粉丝点击