HL1 player angles

Very early version, many mistakes indeed.

This document deals with player angles in Half-life 1.

This document is good for understanding mess with player angles :)

Newest version of this document will be found on http://neuron.tuke.sk/~wagner someday

Copyright © 2005 Jozef Wagner, http://neuron.tuke.sk/~wagner

Sketch

Player Angles

click above for player angles sketch, the most important part of this document. (15149 bytes)

Warm-up

entity structure (edict_t and edict_s are the same) is declared in engine/edict.h in Half-Life SDK. Every entity has one instance of this structure.

Important part of the edict_t structure is variable v of type entvars_t. This type is declared in engine/progdefs.h in Half-Life SDK.

Player Angles

Player entities have 2 important variables dealing with players current state. (in entvars_t structure, named v)

  • angles - players body angle
  • v_angle - players viewing angle

These are 3d angles and they are in fact 3d vectors. (in fact array of 3 float variables)

Most important fact about angle system in Half-life is that direction you are looking does not have to be direction of where your body (and head too) is looking. This can cause funny situations when coding a bot; you can make him to shoot from its "ass" :)

Another thing you should know is naming of angles axes :

  • pitch - x part of an angle
  • yaw - y part of an angle
  • roll - z part of an angle

angles

This variable holds players body (model) angles. If you look at your teammate, his direction you see is defined in this varaible.

angles.x

Looking Up/Down pose of players model. Note strange angle scale here. Right angle is 30 here, not 90.

Valid values are [-30, 30]

angles.y

Horizontal looking pose of players model.

Valid values are [-180, 180]

angles.z

A truly weird pose :) Usually not used and you shall set it to 0.

Valid values are [-180, 180]

v_angle

Viewing angle. This angle points to the direction where player is looking and shooting.

v_angle.x

Looking Up/Down. Again some strange things, negative values are Up and positive down.

Valid values are [-90, 90]

v_angle.y

Horizontal looking. Same as angles.y

Valid values are [-180, 180]

v_angle.z

Well I didn't know how to test this. It seems it is unused variable. Set it to 0 :)

Other

Well Half-life engine / game API functions can sometimes return invalid values of angles. You shall convert them back to valid ranges before using them.

Players model is behaving according to angles variable

Players FOV (Field of vision) is using v_angle variable

Actual bullet from players gun is flying in direction of v_angle variable. BUT

Bullet animation (e.g. hitting the wall) is using angles variable. So you can make 'invisible' shots, looking other way and shooting someone at your side, and even bullet sign will be on wall before you.