Getting the Camera's rotation

I am trying to acquire the player camera’s rotation to rotate an object the same angle as the camera.

I run this

cam.CFrame:ToWorldSpace().Rotation.Y

but it just returns zero.
What is the correct way to do something like this?

CFrame:ToEulerAnglesXYZ()

Doesn’t work for my purposes because basically it thinks these two angles are the same
image
image

Workspace.CurrentCamera.cframe:ToEulerAnglesXYZ() should work, note that this returns in radians.

This doesn’t work for my purposes because I am trying to get the rotation of a single axis (Y) and all point with that method have a equal value at the same mirror angle:
Visulization
I need to get the exact angle, not the reference angle

I haven’t solved this yet can someone point out what I should do?

I haven’t tried this myself, but the issue could be that ToEulerAnglesXYZ() calculates as if you applied in X Y Z order, so for one case you could get 0 X and 45 Y, while in another case you’d get 180 X and 45 Y. there’s another function called ToEulerAnglesYXZ() which calculates Y first.

2 Likes

I don’t quite understand your problem. :ToEulerAnglesXYZ() returns a Vector3 value of all the axis, i.e (rx, ry, rz). Thus, just use the Y axis of it?

The way rotation is applied to CFrames depends on the order of operation and because I needed the X rotation, I need to apply Y rotation first, otherwise it would return a reference angle.
So I needed to use