# Get The Angle Of Two Vector3 In Unity

The angle returned of  Vector3.Angle is always the acute angle between the two vector (ie, the smaller of the two possible angles between them and never greater than 180 degrees).

So the angle is the same no matter if "to the left" or "to the right". If you want to know the side, the cross product may help you.

Supposing that both vectors are roughly in the horizontal plane (XZ), the Y component of their cross product may define the sign - for instance:

 function SignedAngle(a: Vector3, b: Vector3){
var angle = Vector3.Angle(a, b); // calculate angle
// assume the sign of the cross product's Y component:
return angle * Mathf.Sign(Vector3.Cross(a, b).y);
}

http://answers.unity3d.com/questions/317648/angle-between-two-vectors.html

http://docs.unity3d.com/ScriptReference/Vector3.Angle.html

07-11 4025
07-26 740                                                                  10-10 399
12-17 1949
03-01 1066
04-18 5241
08-08 5799
11-30 2696
04-23 1202
01-08 2732
01-02 225
09-02 4154
05-12 2万+
04-05 1万+
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客