Hi all, I’ve been searching for a solution to this issue for some time now but couldn’t find anything. Basically I’m trying to make a camera rotate with the Delta from the user’s mouse, but the camera starts tilting weirdly at a certain point.
Ideally it should just be a view moving horizontally and vertically and not tilt like it is in the video. I don’t really have a firm grasp on what CFrame.Angles() actually is doing in this case, though I know to achieve this the Z axis needs to be somehow calculated but I don’t know how to do so.
You could set the camera’s CFrame to a new CFrame containing the current position of the camera, and the position + the LookVector of the camera, which would essentially reset the Z axis. This goes after the camera’s CFrame is set.
local x = DeltaX * SENSITIVITY
local y = DeltaY * SENSITIVITY
self.Camera.CFrame = CFrame.new(self.Camera.CFrame.Position) * CFrame.Angles(0, x, 0) * CFrame.Angles(y, 0, 0)
Rotations are applied in local space of the current CFrame, or they’re applied relative to the current CFrame, as you might say - Euler angles can get pretty wack sometimes