Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

get 2d rotation from 2 position math

Vector3 dir = new Vector3(position2.x - position1.x, position2.y - position1.y);
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
Quaternion rotation = Quaternion.Euler( 0f, 0f, angle );
 
PREVIOUS NEXT
Tagged: #rotation #position #math
ADD COMMENT
Topic
Name
2+4 =