Recently, I was discussing with another individual about a certain issue regarding CFrames. They came to me stating that they were only turning their object on X and Y axis. I myself am confused by what’s happening and seek an answer, so I’m posting here regarding that.
Image of the camera in a tilted stance:
The cameras are being appropriately turned using CFrame.Angles, inputs in radians and turning only along horizontal and vertical axis (up-down, left-right, in simple terms). That being said, it seems that the camera makes odd twisting movements such as the above.
A GIF of what’s happening while the camera is being utilised:
https://gyazo.com/3af44e33b1851a21305227b8d8665d11
As for the assembly of the camera, it is like so:
The red block represents the PrimaryPart which serves as the basis for determining where the camera model should be aimed at, while the red ball represents what the CurrentCamera CFrame is set to.
Perhaps its an issue in the way the assembly is created, or what inputs are being applied in the CFrame.Angles method? Maybe it’s in object-space as opposed to world space? Not too sure.
To note, the CFrame.Angles statement looks like this:
If there is not information accompanying this thread to solve this specific problem, then what I’d like to know is what kind of math would be applicable here in order to ensure that my camera is turning in an appropriate mannerism. I’ve created a rough assembly to demonstrate what I seek.
(Assembly appearance)
(Surface normals for PrimaryPart)
(Camera needs to be able to move vertically, horizontally or do both at the same time. Don’t worry about clamping, I can handle that. What matters is being able to solve the rotation issue.)