How can I set the rotation to my actor?

I tried this code for my actor rotation change (10, 20, 30) to (100, 200, 300).

void AMyActor::SetMyRotation()
{
	FRotator RotB = GetActorRotation();
	UE_LOG(LogTemp, Log, TEXT("Rotation(Before): %f, %f, %f"), RotB.Roll, RotB.Pitch, RotB.Yaw); // Correct

	FRotator MyRot;
	MyRot.Roll = 100.0f;
	MyRot.Pitch = 200.0f;
	MyRot.Yaw = 300.0f;

	//SetActorRotation(MyRot);
	SetActorRelativeRotation(MyRot);

	FRotator RotA = GetActorRotation();
	UE_LOG(LogTemp, Log, TEXT("Rotation(After): %f, %f, %f"), RotA.Roll, RotA.Pitch, RotA.Yaw); // Wrong?
}

But, I don’t get the correct rotation (100, 200, 300).

(SetActorRotation() &SetActorRelativeRotation() are same result.)

How can I do it?

Thank you.

85196-rotation1.jpg

There’s nothing wrong with the output. The ‘After’ rotation you see is equivalent to the one you entered - both produce the same end rotation. There’s more than one way to represent a rotation in 3D using 3 axes. When you enter the values in code, it internally converts it to a different form (Quaternions) and when you ask for it back, it reconverts it to Euler angles which can look different than the original. These problems in how numbers look (called Gimbal Lock) are especially problematic if you’re using Euler angles to interpolate all 3 axes smoothly.

I understand.
I will study Quaternions.

Thank you for your good answer.