CFrame Orientation not as supplied

Hello, currently I am trying to create a camera for use in a ViewportFrame I can correctly set the CFrame Positions but not the Orientations.

The camera type is set to scriptable.

local pos = Vector3.new(-5.118, 1005.512, -167.479)
camera.CFrame = CFrame.new(pos)
camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(-16.485), math.rad(-142.803), 0)

I have researched for many solutions and understand the roatation is applied in ZYX order.

image0-10

The above is the orientation this code produces.

If you want the same angles in the orientation then you should use

CFrame:fromEulerAnglesYXZ() or the equivalent CFrame:fromOrientation()

local pos = Vector3.new(-5.118, 1005.512, -167.479)
camera.CFrame = CFrame.new(pos)
camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesYXZ(math.rad(-16.485), math.rad(-142.803), 0)

Should produce the result that I believe you’re looking for.

Thank you that has fixed the issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.