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. )