How do I tilt the camera?

I am trying to tilt the camera by degrees.

I have tried something like this to tilt the camera on the Y axis, but it does not work:

game.Workspace.CurrentCamera.CFrame = CFrame.new() * CFrame.Angles(0, 0, 10)

How would I go about tilting the camera on the Y axis?

3 Likes

CFrame.new() creates a new CFrame without accounting for the previous value so a better option would be too simlpy use CurrentCamera.CFrame instead. Also, CFrame.Angles takes the parameters as radians and not degrees so you need to do CFrame.Angles(0, 0, math.rad(10)) which converts degrees to radians. It should all come togethor to look like this. Dont forget to mark this as a solution if it helped :grin:

local cam  = game.Workspace.CurrentCamera
cam.CFrame = cam.CFrame * CFrame.Angles(0, 0, math.rad(10))
8 Likes

Another method to consider is CFrame.fromAxisAngle() -

local yAXIS = Vector3.new(0, 1, 0)
local degrees = 30

local cam = workspace.CurrentCamera
cam.CFrame = cam.CFrame * CFrame.fromAxisAngle(yAXIS, math.rad(degrees))

and if you want to rotate it on the y axis in world space, replace the last line with this:

cam.CFrame = cam.CFrame * CFrame.fromAxisAngle(cam.CFrame:VectorToObjectSpace(yAXIS), math.rad(degrees))
3 Likes

Sorry for making this the solution so late. It was night time for me. But hey, thanks! But one more question: do I have to run this every render stepped because it seems to reset everytime it steps.

1 Like

Yup, if you bind it to renderstep it should be fine

1 Like