I’m trying to create a custom camera controller for a first-person game, but the camera “tilts” instead of “nodding” when it looks to the side.
rs.RenderStepped:Connect(function(dt)
uis.MouseBehavior = Enum.MouseBehavior.LockCenter;
delt = uis:GetMouseDelta();
mX = math.rad(-delt.X);
mY = math.rad(-delt.Y);
mXA += mX;
mYA = math.clamp(mYA+mY, math.rad(-80), math.rad(80));
cam.CFrame = CFrame.fromEulerAnglesXYZ(mYA, mXA, 0);
end)
I tried using :ToObjectSpace
but couldn’t figure out how to use it here. I also tried using sin and cos to switch between rotating the Y and Z axis based on the X but it was a little glitchy. So how could I stop it from tilting?
Any help is appreciated