Slerp camera position around point? ( Dampened camera movement. )

I am trying to create a custom camera. I want there to be a dampening effect when moving the camera. The camera will be a set distance from a point.

I have tried using :Lerp(), but the CFrame positions just cut corners and move through the spherical camera space to get to its new location. The angles lerp just fine.

Is there a reasonably easy way to do this? I have looked for something similar already, but only found dead ends.

Here is what I am doing now:


	local XAngle = 0
	local YAngle = 0

InputService.InputChanged:Connect(function(Input, gameProcessed)
	
	if Input.UserInputType == Enum.UserInputType.MouseMovement then
		
		local Delta = InputService:GetMouseDelta()
		local DeltaX = Delta.X
		local DeltaY = Delta.Y		
		
		XAngle = XAngle - DeltaX * .4
    	YAngle = math.clamp(YAngle - DeltaY * .4, -80, 80)
		
		
		Camera.CFrame = Camera.CFrame:Lerp(CFrame.new(Root.Position + Vector3.new(0, 2, 0)) * CFrame.Angles(0, math.rad(XAngle), 0) * CFrame.Angles(math.rad(YAngle), 0, 0) 
		* CFrame.new(0, 2, 10), .25)


		
	end

	
end)

( I am aware that this will only update when the mouse is moved, which causes some unintended behavior as of now. )

1 Like

I’m not sure I completely understand what you’re trying to do but is it possible to create two seperate CFrame variables (one for positioning and one for angles) then lerp the angles and not lerp the position, then set the cframe based on the cframe variables multiplied by eachother?

1 Like