Hi!
I’m using Unreal 5.2.1 and I’m trying to understand Enhanced input with C++. I have create a test project which inherits from Third Persona Template.
Reading the code, I don’t understand this:
void AInputActionTestCharacter::Move(const FInputActionValue& Value)
{
// input is a Vector2D
FVector2D MovementVector = Value.Get<FVector2D>();
if (Controller != nullptr)
{
// find out which way is forward
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get forward vector
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
// get right vector
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
// add movement
AddMovementInput(ForwardDirection, MovementVector.Y);
AddMovementInput(RightDirection, MovementVector.X);
}
}
I don’t know why, if it uses EAxis::X
with ForwardDirection
, then if use Y
axis with ForwardDirection
in AddMovementInput(ForwardDirection, MovementVector.Y);
.
By the way, I have copied this code into my own project and, using the keys W
and S
, when I press W
the character moves to the right, and with S
to the left.
Is there something wrong in the code?
Could someone explain this to me?
Note: I have found the modifier Swizzle Input Axis Values
, but I don’t understand the word Swizzle
.
Thanks!