WisePYR: Pitch Yaw Roll

From Valve Developer Community
Jump to: navigation, search

This tutorial was originally created by wisemx.

Ported from SDKnuts.net to VDC by: Pinsplash (talk) 08:56, 25 June 2018 (UTC)

Every object in the game has an origin. A set of angles are also used to determine the objects orientation in the world. These angles are X, Y and Z also known as Roll, Pitch and Yaw.

  • Roll
Is most often a term used to describe rotation but as you know it has a wide use and is a term in Aeronautics to describe an aircraft rotating on its X axis.
  • Pitch
Is a term derived from the force of pitching an object, such as the way you would pitch hay. It has been used for a very long time to describe the way a ship at sea rocks Fore and Aft along the Y axis. Most often it is used for the same effect on aircraft.
  • Yaw
Is a deviation or turning from side to side. Used in yachting and aeronautics it is an angle that can be used to calculate a coarse deviation along the Z axis.

Take a look at the Pitch, Yaw and Roll keyvalue for a light_environment entity. Each of the 0’s can change from 0 to 360 degrees, in most cases 180 or less. Since the first angle is for the Pitch we can point the light_environment straight down by changing those numbers to 90 0 0. Straight up would be -90 0 0. Most of the questions I get about Pitch Yaw and Roll have to do with the movement of doors and buttons. To help illustrate how these angles work in your map I’ve created a sample project with 10 func_door entities.

These are the angles for each door and the direction in which they move.

1) -90 0 0, Up

1a) -90 0 0, Up

2) 90 0 0, Down

2a) 90 0 0, Down

3) 0 180 0, Left

3a) 0 180 0, Left

4) 0 0 0, Right

4a) 0 0 0, Right

5) 0 90 90, Left

6) 0 -90 -90, Right

The 10 doors in the sample project are all set to open and close every 3 seconds. If you run the project and watch the doors you will see that doors 1 and 1a move exactly alike as do 2 and 2a, however doors 3 and 3a plus doors 4 and 4a do not move exactly alike even though they are exact copies of each other. This is because I rotated each of the backside doors, 1a, 2a, 3a and 4a. Since doors 1 and 2 are moving up and down rotating them did not affect the copies 1a and 2a. However since the copies of 3 and 4 have changed we need to adjust the Pitch Yaw and Roll to make them move properly. The doors 5 and 6 are copies of 3 and 4 but with the correct movement. As you can see to make door 5 move properly we had to change 0 180 0 to 0 90 90.

See Also