When I do the example about First Person Shooter C++ Tutorial,I meet a question,please see the following code:
void AFPSCharacter::MoveForward(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
// find out which way is forward
FRotator Rotation = Controller->GetControlRotation();
// Limit pitch when walking or falling
if (GetCharacterMovement()->IsMovingOnGround() || GetCharacterMovement()->IsFalling())
{
Rotation.Pitch = 0.0f;
}
// add movement in that direction
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
I know MoveForward means add a offset to the controller’s Forward direction. I also understand the code FRotationMatrix(Rotation) means get matrix from a Rotation,Direction represent controller’s forward direction,it will be added a offset (Value int the code),but what dose the function GetScaledAxis mean? When I open source code in FMatrix.cpp,it only return a component of matrix (it is decided by the function’s parameter). There parameter is EAxis::X,so it will return FVector(M[0][0], M[0][1], M[0][2]) to Direction ,why? dose it mean the matrix’s X component represent forward direction? I feel so confuse about it. Now I even don’t know ue4 use right hand Coordinate or left hand Coordinate. In the level editor,the Z axis is upforward, Y axis is backforward, these are not like the form of opengl or directx, so it confuse me too. I hope someone can help me resolve this question,thanks!