Hi there. I am currently trying to rotate a part, a plane or ship for example, without experiencing gimbal lock.
Let’s say I have a part and I want to set it’s X rotation to 90.
part.CFrame = CFrame.Angles(math.rad(90), 0, 0);
does the trick. But now, let’s say that I want to set the Y axis to 90.
Now, let’s set X to 45. What happens is this makes the part rotate 45 degrees on the Z axis. Not what I want.
Let me visualize this:
In the first few seconds, I show how the part can rotate fine on the X axis whilst the Y and Z axis are both 0. Then, I set the Y axis to -90 and try to rotate the X axis again, except now it rotates on the Z axis. This is gimbal lock.
So you may ask, why not just do the 'ol
part.CFrame = part.CFrame * CFrame.Angles(speedX, speedY, speedZ)
Well, the reason is that I do not want to apply a constant rotational speed, I want to set the rotation. I’ve tried to subtract the current rotation from the target angle to find the difference but this produces an odd jittering effect (as in, the arrow shown here has a full out seizure) when it hits certain angles, so I am not certain if that solution would work.
Are there any ways to fully resolve gimbal lock, without using quaternions or applying rotational speed in real-time? I feel like there would be, given that I’ve seen other people do what I’m attempting to achieve without quaternions, but I’m not sure.