Vector3.Anglestatic function Angle (from : Vector3, to : Vector3) : floatDescriptionReturns 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"); } |
