Vector3.Angle Manual     Reference     Scripting  
Scripting > Runtime Classes > Vector3
Vector3.Angle

static function Angle (from : Vector3, to : Vector3) : float

Description

Returns the angle in degrees between from and to.

// prints "close" if the z-axis of this transform looks
// almost towards the target
var target : Transform;
function Update () {
var targetDir = target.position - transform.position;
var forward = transform.forward;
var angle = Vector3.Angle(targetDir, forward);
if (angle < 5.0)
print("close");
}