Vector3
- Angle
- ClampMagnitude
- Cross
- Distance
- Dot
- forward
- Lerp
- magnitude
- Max
- Min
- MoveTowards
- normalized
- Normalize
- one
- operator !=
- operator *
- operator +
- operator -
- operator /
- operator ==
- OrthoNormalize
- Project
- Reflect
- right
- RotateTowards
- Scale
- Slerp
- SmoothDamp
- sqrMagnitude
- this [int index]
- ToString
- up
- Vector3
- x
- y
- zero
- z
Vector3.Distance 距离
static function Distance (a : Vector3, b : Vector3) : float
Description描述
Returns the distance between a and b.
返回a和b之间的距离。
Vector3.Distance(a,b) is the same as (a-b).magnitude
Vector3.Distance(a,b) 等同于(a-b).magnitude 。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Transform other;
public void Awake() {
if (typeof(other)) {
float dist = Vector3.Distance(other.position, transform.position);
print("Distance to other: " + dist);
}
}
}
var other : Transform;
if (other) {
var dist = Vector3.Distance(other.position, transform.position);
print ("Distance to other: " + dist);
}
最后修改:2010年12月20日 Monday 22:11