Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I get the camera rotation CFrame?

Asked by 6 years ago

Essentially I'm trying to get the orientation of the camera (like how parts have an orientation property), but I don't see the camera having that.

I can get the camera CFrame with game.Workspace.CurrentCamera.CFrame, but I'm not sure how to find what the rotation vector is out of this cframe.

1 answer

Log in to vote
3
Answered by 6 years ago

CFrames have a LookVector, RightVector, and UpVector properties which are the components that describes the CFrames orientation using unit vectors.

But if you were looking for angles (in radians) toEulerAnglesXYZ is a method of CFrame that returns those angles as a tuple:

local x, y, z = cf:toEulerAnglesXYZ() -- in radians

It could then be used in CFrame.Angles

CFrame.new(0, 0, 0) * CFrame.Angles(x, y, z) -- create another CFrame with a position of 0, 0, 0
-- and the same rotation as cf
0
I comfrirm ScriptAbyss 10 — 6y
Ad

Answer this question