Vector3.Angle

Unity3D/Problems 2016. 12. 3. 04:13
반응형

it is quite simpe if you know the conditions clearly.
This image illustrates it (i am using x/z axis):



the code would be like:

Code (csharp):
  1.  
  2. var A:Vector3 = Vector3( 0.00.01.0 ) // x,y,z
  3. var B:Vector3 = Vector3( 1.00.01.0 ) // x,y,z
  4. var angle:float = Vector3.Angle( A,B );
  5.     // angle == 45
  6.  
  7. Debug.DrawLine ( Vector3.zero, A, color.yellow );
  8. Debug.DrawLine ( Vector3.zero, B, color.yellow );
  9.  

so what we do here is set the Vector A along the z-axis and the Vector B along the x/z plane.

The important thing to understand is that (if i'm not mixed up) Vector3.Angle always calculates the angle from the Vector3.zero to the actual Points.

반응형
: