Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

vectoyaw

From Quake Wiki

Revision as of 12:24, 31 July 2023 by Boondorl (talk | contribs)

float vectoyaw(vector vec)

Usage

Gets the arc tangent of the vector's x and y values. This is equivalent to atan2 in other programming languages.

Parameters

  • vec
Stores the x and y arguments to pass to atan2. The z value does nothing.

Return

The angle of the x and y components of the vector. Can be a value in the range [0, 360).

Example

// Checks to see if the monster's enemy is in front of them before attacking.
float yawTo = vectoyaw(self.enemy.origin - self.origin);

float delta = anglemod(self.angles.y - yawTo);
if (delta > 45 && delta < 315)
    return;