$ ./guess_the_languageGame Dev
Game Dev · medium · #111

What does Atan2 compute here?

angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
  1. The heading angle of a vector
  2. The length of the vector
  3. The dot product result
  4. A random spread offset
Atan2(y, x) returns the direction angle, handling all quadrants.
Play Game Dev ▸