How to manipulate ACharacter's FRotator... ??

I Solved my issue! I keep the original bellow for anyone interested.

The solution is to apply the modification to the Controller behind the ACharacter as such:

...
ANWPlayerController *ThisPlayerController = Cast<ANWPlayerController>(GetController());
FRotator ControlRotation = ThisPlayerController->GetControlRotation();
ControlRotation.Yaw += AxisValue;
ThisPlayerController->SetControlRotation(ControlRotation);

This makes sense because characters, I assume, inherit a transform from the controller which possesses them… I never knew that! I think this is not super clear from the get-go or I just missed the info.


Hi Everyone,

(Unreal 5.1)

I’m a beginner in UE5 getting frustrated on something quite simple. Look at this code and please tell me what I’m missing.

I created a child class of ACharacter and tried to make it rotate. I have a basic method taking the AxisValue of MouseX. The method should add AxisValue to the current FRotator of the character.

void ANWCharacterBase::LookLeftRight(const float AxisValue) {
	
	FRotator ActorRotator = FRotator(0.f, AxisValue, 0.f);

	const FQuat QuatRotation = FQuat(ActorRotator);

	AddActorWorldRotation(QuatRotation, false, 0, ETeleportType::None);
}

When I try it, however, it doesn’t work. It’s as if the FRotator is always reset to (0, 0, 90) even if it is being set in AddActorWorldRotation right there… I can see my character “rotate slightly” and then coming back to this default angle. So I know that AxisValue is NOT zero and that the input code is in fact feeding in the proper value to the method’s argument. In fact, my code for looking up and down works fine. (It uses the SpringArm, which is why I’m not facing the same issue.)

Out of curiosity, I looked in the implementation of AddActorWorldRotation and it seems to me like it is setting the RelativeRotation.
I also tried AddActorLocalRotation first, because it sounded more appropriate. However, it also didn’t work.

So, I assume I am missing some understanding about rotations. Why am I unable to “add” a small value to the current rotation ? I would need to get a little help with this one.

Also, side-note, I am using the new Enhanced Input System, which seems to have made AddControllerYawInput method dysfunctional at the present, which is why I am re-writing this rotation code.