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

Editing makevectors

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''void'' '''makevectors'''(''vector'' angs)
+
Syntax:<br/>
 +
<code>makevectors(vector angles)</code>
  
== Usage ==
+
Creates relative forward, right and up vectors with length 1 from angles. These 3 directional vectors are stored in the global variables <code>v_forward</code>, <code>v_right</code> and <code>v_up</code> respectively.
Takes the passed angles and converts them into its three local axes i.e. its 3D rotation matrix. This is useful if you need to offset relative to an angle e.g. in the direction an entity is facing. Sets the following globals:
+
Note that because these are global variables, running makevectors on another set of angles will destroy the previously calculated vectors.
*'''v_forward'''
 
:The facing direction of the passed angles.
 
*'''v_up'''
 
:The direction pointing 90 degrees up from the facing direction of the passed angles.
 
*'''v_right'''
 
:The direction pointing 90 degrees to the right of the facing direction of the passed angles.
 
 
 
'''Warning:''' A bug exists with <code>vectoangles()</code> where the pitch is not negated correctly. If you pass the results of this function or the '''angles''' field of an entity, the pitch (the x value) must be negated first.
 
 
 
=== Parameters ===
 
*''angs''
 
:The angles that will be used to generate the axes as (pitch, yaw, roll).
 
 
 
== Example ==
 
// Get the axes in the direction the player is looking
 
makevectors(player.v_angle);
 
 
// Offset 1024 map units in the direction the player is looking
 
traceline(player.origin, player.origin + v_forward*1024, 0, player);
 
 
 
[[Category:QuakeC Function]]
 

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)