What does Atan2 compute here?
angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
- The heading angle of a vector
- The length of the vector
- The dot product result
- A random spread offset
Atan2(y, x) returns the direction angle, handling all quadrants.
Play Game Dev ▸