Download

Why is Character not rotating to direction?

I know my direction is correct since I used “Move To Direction Test” commented out code. It moves to correct direction but my character does not rotate to it. I want to do it manually and not automatically.


 FRotator Rotation = CharacterOwner->GetControlRotation();

if (CameraActor != nullptr)
Rotation = CameraActor->GetActorRotation();

FRotator YawRotation(0, Rotation.Yaw, 0);
FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);

//Move To Direction Test 
//CharacterOwner->AddMovementInput(Direction, FVector(InputZ,InputX,0).Size());

CharacterOwner->AddMovementInput(CharacterOwner->GetActorForwardVector(), FVector(InputZ, InputX, 0).Size());

CharacterOwner->SetActorRotation(UKismetMathLibrary::MakeRotator(Direction.ForwardVector.X, Direction.ForwardVector.Y,Direction.ForwardVector.Z));