Hi, I’m trying to learn UE coding and started with the FPS Tutorial.
I’m stuck to understand why in this code you need to check the pitch and set it to 0.0f:
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);
}
}
Isn’t the pitch involve the Y axis while I’m extracting from the rotation matrix the X info into a vector?
When I go to extract the Y instead I don’t check anything:
void AFPSCharacter::MoveRight(float Value)
{
if ( (Controller != NULL) && (Value != 0.0f) )
{
// find out which way is right
const FRotator Rotation = Controller->GetControlRotation();
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
// add movement in that direction
AddMovementInput(Direction, Value);
}
}
In the FPS template the GetActorForwardVector() is used instead of the above code, can I assume this function does the same.