Download

Understanding Rotation vs Location

This is a complete newb question. I am coming from Unity and I’m walking through some examples. I found the following code


 
 void AFPSCharacter::MoveForward(float Value)  {      // Find out which way is "forward" and record that the player wants to move that way.      FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::X);      AddMovementInput(Direction, Value);  } 

in the FPS tutorial. In MoveForward() how does getting the rotation of the X axis determine how we can move forward? Wouldn’t that simply keeps us in the same position while we rotate around the X axis?
BTW - I have no idea why this code isn’t wrapping. Sorry.

A Rotation is Roll Pitch and Yaw while a Direction and a Location is X Y Z coordinates that only differ by their use. While converting a Rotation to a Direction you mostly want to pick the X axis since that is the forward Axis.

Ok, that’s what I figured. But why would I want to convert the pitch to a forward direction instead of just using my ‘W’ key to change the X location directly?

You can of course move in the local forward Direction if you want that but in the example it is taken from the Controller Rotation. The Controller is often used to “drive” Pawns since the Controller could be consuming the input etc instead of handling it on the Pawn directly.