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

vectoangles

From Quake Wiki

Revision as of 15:31, 1 August 2023 by Boondorl (talk | contribs)

vector vectoangles(vector vec)

Usage

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

Parameters

  • vec
The vector to get the angles from.

Return

The yaw and pitch in a vector as (pitch, yaw, 0).

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

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