How works Add Controller Yaw (or Pitch) Input

Hi guys,

I don’t understand the Add Controller Yaw (Pitch) Input function in Blueprints.
The documentation says: “Add input(affecting Yaw) to the Controller’s ControlRotation, if it is a local PlayerController. This value is multiplied by the PlayerController’s InputYawScale value”.

In the ThirdPerson Blueprint Example:
I am adding via “InputAxis Turn” the value of my mouse to the PlayerController of the Character. But the Target of “Add Controller Yaw Input” is Pawn, not PlayerController.

I just don’t get it. :smiley:
Please tell me this kind of magic. :smiley:

PS: Sorry for my English.

1 Like

Lets say someone is using a joystick to turn their character. They do a hard left, so that the input axis is -1. If the game samples the state of the hardware, it’ll get a -1 value on the input axis. You can apply a sensitivity value as well which is a multiplier for the input axis. I think the yaw is a default of 2.5. The input axis is multiplied by this value, and then it accrues until the controlled tick method has processed it.

The controller will take the accrued yaw value and apply it to the rotation of whatever object it is controlling. So, if you’re controller is controlling a space ship and someone has a hard left on the joystick and your sensitivity it 2.5, the result will be:

TotalYaw += -1 * 2.5;

So the space ship will turn to the left by -2.5 degrees.

It’s better to do your input processing in the player controller as well. Let’s pretend you have five different space ships and each one handles differently. The input sensitivity if the players hardware is a player set preference. The response of the ship to the inputs is a game designer set preference. So, you could have a space ship which is slow and bulky which turns very slowly when someone is giving it a hard left turn. All the player controller would be doing is saying, “Turn hard to the left!”, and the ship would be saying, “Okay, this is how hard I can turn to the left…”

Keep in mind, the player controller can have multiple input methods which all result in a hard left turn. Maybe you support joysticks, mouse and keyboard, game pads, or VR controllers. They all create input actions which get converted into commands to your controlled pawn via your controller.

1 Like

Hey Slyermin,
thank you for your awesome answer!
I think i understand.

You can apply a sensitivity value as well which is a multiplier for the input axis.

This means the Pawn has a Attribute for this, which i can set in the class Defaults?


It’s better to do your input processing in the player controller as well
So i go in my PlayerController Blueprint, do a “Get Controlled Pawn” and set the Function “Add Controller Yaw Input” with my Input?

The sensitivity value for your axis is actually in your player controller class. If you create a blueprint which inherits from the player controller, you should be able to see it in the details panel and change it.

When you call “Add Controller Yaw Input” from the controlled pawn, it’s calling back to the player controller to apply that. So, you’d be doing a redundant call with that. Maybe I’m doing this the hard way, but what I did was I created an interface for input which all of my characters implement. The interface has a “Turn” method which the classes have to implement. When the player controller gets the turn event from input, it just sends an interface message to whatever pawn it’s controlling, and that pawn is responsible for turning. This gets a little more clear when you have other inputs such as “jump” and “crouch” and some creatures may not have those abilities, even though the player pressed input buttons to have the creature jump and crouch.