I am trying to understand why my character is not rotating towards the desired input.
Any help is appreciated.
I implemented the following function for movement
void AMainPlayerController::Move(const FInputActionValue& Value)
{
// input is a Vector2D
FVector2D MovementVector = Value.Get<FVector2D>();
// Only proceed if there is a significant movement input
if (!MovementVector.IsNearlyZero())
{
// Transform the input vector into a 3D vector with no Z component
FVector InputVector = FVector(MovementVector, 0);
// Get the rotation of the input vector
FRotator MovementRotator = InputVector.Rotation();
// Get the pawn that is being controlled by this controller
APawn* ControlledPawn = GetPawn();
if (ControlledPawn)
{
// Set the rotation of the pawn to the rotation of the input vector
ControlledPawn->SetActorRotation(MovementRotator);
// Move the pawn in the direction of the input vector
ControlledPawn->AddMovementInput(InputVector, MovementSpeed, false);
}
}
}