How to Rotate a camera around world Y axis

You can write your topic however you want, but you need to answer these questions:

I. I want to rotate a camera through a script around the world Y axis, so the Z rotation is not affected.

  1. My camera turn around it’s local Y axis so it’s rolling, i’m quite new to CFrame and object/world space so i don’t really know how to achieve that.

  2. I search alot and i tried to understand Object/World space, and operation with CFrame, but the part i still rotating around it’s own Y axis.

This is my code :

local function TurnLeft()
	
	while AInput == true do
		
		camera.CFrame = camera.CFrame * CFrame.Angles(0, math.rad(2), 0)
		task.wait()
	end
end

local function TurnRight()
	
	while DInput == true do
		
		camera.CFrame = camera.CFrame * (CFrame.Angles(0, math.rad(-2), 0))
		task.wait()
	end
end

I put back the “camera.CFrame * (CFrame.Angles(0, math.rad(-2), 0))” because nothing i tried worked.

After More thinking and try, i found that

CFrame.new(camera.CFrame.Position) * CFrame.Angles(0, math.rad(2), 0) * camera.CFrame.Rotation

work perfectly, but i’m not entirely sure why it’s working or if it’s the best way to achieve it, so if you know a better way to do it, or an explanation why it’s working i would really appreciate.

1 Like

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