Hey everyone,
I am programming a little project right now and have encountered a little problem.
My character moves fine, but doesn’t rotate in the direction he moves to. I have tried everything I know of so far, I even looked thoroughly through the third person template from Unreal but to no avail. I hope anyone here can tell me, otherwise I need to do it via workaround.
Below is my code so far! It looks to me that the rotation is immediately overwritten by something else. I can see that when I pause and set the rotation manually, as soon as I hit play the rotation is set to zero again.
Oh and just for context, my camera can not be controlled in any way. it follows the player around at a fixed distance.
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 + 1, 0);
// get forward vector
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
// get right vector
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
// add movement
AddMovementInput(ForwardDirection, MovementVector.Y);
AddMovementInput(RightDirection, MovementVector.X);