I’m using a quaternion (obtained by a simple ArcBall system) to rotate an actor. Everything is working great!
(Important note: It doesn’t work very well if I convert it to Euler before applying the rotation )
But problem arises as soon as I try to make it rotate only by 10 degrees.
I tried using a FRotator:
FQuat MyRotation = GetMyArcBall()->GetRotationQuat(); // My code, get the rotation quaternion // ... const int rotationStep = 10; // TODO: Add a setting for this FRotator CurrentRotator = MyRotation.Rotator(); float YawMod = FMath::Fmod(CurrentRotator.Yaw, rotationStep); float YawAdjustment = -YawMod; if (YawMod > (rotationStep / 2)) YawAdjustment = (rotationStep - YawMod); FQuat RotationStepAdjustment(FRotator(0.f, YawAdjustment, 0.f)); MyRotation = RotationStepAdjustment * MyRotation;
This works nicely. But if I try the exact same code for Pitch, the rotation freaks out! (with the obvious replacement, below)
FQuat RotationStepAdjustment(FRotator(PitchAdjustment, 0.f, 0.f));
I’m trying to fix this for a gooooood while now
From what I understood, I’d need to modify the x,y,z part of the quaternion, without touching the w part. Still, I’m having a hard time to understand how to do that properly.
Can someone give me a hand in this?
Thank you very much in advance!