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

vectoangles

From Quake Wiki

vector vectoangles(vector vec)

Usage[edit]

Calculates the yaw and pitch of the passed vector. Useful for converting a direction back into angles e.g. a missile's velocity.

Parameters[edit]

  • vec
The vector to get the angles from.

Return[edit]

The yaw and pitch in a vector as (pitch, yaw, 0). Values range from [0, 360).

Warning: Due to an oversight, the pitch value this function returns is negated. This works fine if setting it to angles, but if you're using it with makevectors() be sure to negate the pitch (the x value) first.

Example[edit]

// After a missile calculates its velocity, set its angles to match
missile.velocity = dir * 1024;
missile.angles = vectoangles(missile.velocity);