I extended the class CharacterMovementComponent to implement new movement features.
I need to rotate the character so I’ve written this code:
void UMyCharMovementComponent::PerformMovement(float DeltaTime) {
Super::PerformMovement(DeltaTime);
ACharacter* Character = GetCharacterOwner();
if (!Character) {
return;
}
float CurrentOrientation = Character->GetActorRotation().Yaw + RotationSpeed * DeltaTime;
Character->SetActorRotation(FRotator(0.f, CurrentOrientation, 0.f));
}
The RotationSpeed is controlled into the tick function
The problem is that each tick the rotation will be reset to the initial, the result is the pawn that is vibrating.
What is the correct way to rotate the character?