Hello, I currently have a realistic car camera that sets the scriptable camera CFrame to the CFrame of the primary part of the vehicle you are driving (plus an offset). However, the camera is very jittery since the vehicle itself vibrates slightly up and down. Is there a way to smooth/dampen the camera movements?
Adjusting Lerp or Tween settings do not seem to mitigate this issue, and rounding the camera cframe to fewer significant figures does not have the desired smoothed effect.
I can think of a way to spoof this by adding math to the look and right vectors so it snaps to position in X and Z, but it doesn’t feel like a clean solution
You would need to combine vectors and lerp them. Here’s an example:
local currentPosY = Vector3.new(0, 0, 0) --store this somewhere at the top of your script
local posXZ = position * Vector3.new(1, 0, 1) --X and Z position
local posY = position * Vector3.new(0, 1, 0) --Y position
currentPosY = currentPosY:lerp(posY, 0.1) --lerp the position to the new position
local pos = currentPosY + posXZ --this will be your position with X, Y, and Z
--for a CFrame:
local newCamCF = part.CFrame.Rotation * CFrame.new(pos) --Add the rotation with no translation and the desired position.
The approach you sent seems sound, though I was hoping to do something in local coordinates. Using global Y wouldn’t quite work on steep inclines, where the vertical springs aren’t straight up and down.
Here is a sample of my existing code for more context
local offsetCFrame = CFrame.new(0, 1.5, 7)
local combCFrame = Character.PrimaryPart.CFrame * offsetCFrame
cam.CFrame = cam.CFrame:Lerp(combCFrame, 0.15)