Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "vectoangles"
From Quake Wiki
m (Move page script moved page Vectoangles to vectoangles: Fixing the case) |
|||
Line 1: | Line 1: | ||
− | + | ''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 <code>makevectors()</code> 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); |
Revision as of 15:31, 1 August 2023
vector vectoangles(vector vec)
Contents
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);