How to make camera movement smoother?

I’m trying to make an over-the-shoulder camera system and I’m using CFrame:Lerp to make the camera lag slightly behind the mouse movement to make it feel smoother, but it ends up looking jittery and sometimes the player doesn’t end up facing where it should. Any ideas how to fix?

Here’s my code:

	local function playerInput(actionName, inputState, inputObject)
		-- Calculate camera/player rotation on input change
		if inputState == Enum.UserInputState.Change then
			cameraAngleX = cameraAngleX - inputObject.Delta.X
			-- Reduce vertical mouse/touch sensitivity and clamp vertical axis
			cameraAngleY = math.clamp(cameraAngleY-inputObject.Delta.Y*0.4, -75, 75)
			-- Rotate root part CFrame by X delta
			local rootPartCFrame = rootPart.CFrame
			local newRootPartCFrame = CFrame.new(rootPart.Position) * CFrame.Angles(0, math.rad(cameraAngleX), 0)
			rootPart.CFrame = rootPartCFrame:Lerp(newRootPartCFrame, 0.35)
		end
	end

A video of the issue: Video

To get what you want you have two options:

  1. Do what I did and script up a giant module for camera control (not worth it at all)

– Or –

  1. Use springs. I have seen many people use springs attached to the camera and the desired destination and then look at the force to see how much to move the camera

Unfortunately, the way Roblox cameras are pre-programmed makes it a bit difficult to customize and get desired behavior. Sorry, I couldn’t provide an exact solution. I would suggest looking into the spring solution, as it is not worth your time to make a giant module unless you are working on a giant project.

2 Likes