Hey there,
I’m working on a script that involves controlling the orientation of the camera in my game. However, I’ve encountered a strange issue where applying rotations in different orders seems to produce different results.
Here’s a snippet of the code:
print("X:", CFrame.Angles(0, math.rad(CameraController.Delta.Y), 0))
print("Y:", CFrame.Angles(math.rad(CameraController.Delta.X), 0, 0))
print("1:", CFrame.Angles(math.rad(CameraController.Delta.X), math.rad(CameraController.Delta.Y), 0))
print("2:", CFrame.Angles(0, math.rad(CameraController.Delta.Y), 0) * CFrame.Angles(math.rad(CameraController.Delta.X), 0, 0))
In theory, the values printed should be identical, as they represent the same final orientation of the camera.
However, I’m seeing different results printed in the console:
X: 0, 0, 0, 0.857167304, 0, 0.515038073, 0, 1, 0, -0.515038073, 0, 0.857167304
Y: 0, 0, 0, 1, 0, 0, 0, 0.992546141, -0.121869348, 0, 0.121869348, 0.992546141
1: 0, 0, 0, 0.857167304, 0, 0.515038073, 0.0627673566, 0.992546141, -0.104462422, -0.511199057, 0.121869348, 0.850778103
2: 0, 0, 0, 0.857167304, 0.0627673566, 0.511199057, 0, 0.992546141, -0.121869348, -0.515038073, 0.104462422, 0.850778103
If anyone can offer insight on why this is happening, I’d really appreciate that.
Thanks!