Learn

Chapter 04 Variables & Data Types

#034 Rotators

A turret that always faces the player. One node finds the angle, and a Rotator stores the result.

  • 1:14 video
  • Written lesson
  • Beginner
Video lesson: Rotators, 1:14

Which way it faces

Location says where something is. It doesn’t say which way it faces.

Every Rotator holds three angles in degrees: Roll, Pitch and Yaw.

  • Yaw turns left and right, around the up axis.
  • Pitch tilts up and down.
  • Roll banks sideways.

On Make Rotator, the pins read X Roll, Y Pitch and Z Yaw. So turning a character is Z, Yaw.

Need the direction it faces? Get Forward Vector turns a rotator into a vector of length one.

Example: a turret tracking the player

Find Look at Rotation takes the turret’s location and the player’s, and returns the rotation toward the player. Set Actor Rotation applies it, so Yaw follows the player around.

But when the player jumps, Pitch tilts the whole turret upward. Break the rotator and keep only the Yaw. Now the turret just turns.

Comparing angles

Set Yaw to 270, read it back, and you can get −90: same direction, different number. Run both values through Normalize Axis, which keeps angles from −180 to 180.

In short

Location says where. Rotation says which way.

Covered in this lesson

  • Rotator
  • Make Rotator
  • Break Rotator
  • Get Forward Vector
  • Find Look at Rotation
  • Set Actor Rotation
  • Normalize Axis

Newsletter

Development updates are coming to your inbox.

The newsletter opens soon. Until then, new lessons, tools and Beach Hunters progress appear first on our channels, linked below.