Shaky chase camera

So I made a chase camera that follows you in the vehicle you are operating, but there’s an issue where it shakes a lot as you are moving in the vehicle. I’ve tried lowering the rate of every time the tween is played, easing styles, easing directions and easing time, but nothing seems to help it

local player = game.Players.LocalPlayer
local cam
local CamDistance = -70
local CamUp = 10


player.CharacterAdded:connect(function(char)
	char.Humanoid.Changed:connect(function(property)
		if property == "Sit" and char.Humanoid.Sit then
			cam = game:GetService("RunService").RenderStepped:connect(function()
				local outZoomCancellation = CamDistance+(char.Head.Velocity.Magnitude/3)
				local position = char.Head.CFrame + (char.Head.CFrame.lookVector * outZoomCancellation) + (char.Head.CFrame.upVector * CamUp)
				local rotation = char.Head.CFrame
				workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
				game.TweenService:Create(workspace.CurrentCamera, TweenInfo.new(.5, 1, 1, 0, false), {CFrame = position, Focus = rotation}):Play()
				workspace.CurrentCamera.FieldOfView = 60+(char.Head.Velocity.Magnitude/15)
			end)
		elseif property == "Sit" and not char.Humanoid.Sit then
			pcall(function() cam:disconnect() end)
		end
	end)
	char.Humanoid.Died:connect(function()
		pcall(function() cam:disconnect() end)
	end)
end)

You can test this yourself by making a LocalScript and putting it in StarterPlayerScripts with the code above.

You do not want to “tween” every frame. It doesn’t make sense. You won’t be able to observe any of the tweening because the tween is replaced on the next frame. Check out this thread, and the reply I linked to. In relation to your problem, using :lerp is pretty much the same as using TweenService.

I haven’t worked with this sort of thing. I’ve heard the solution is critically dampened springs. You should be able to search the devforums and online to find information about it.

When I use tweening to follow objects I use the Enumerations for both the easing style and easing directions. It’s possible to have it smoothly follow the intended target if you mess with the those two.

TweenInfo.new(0.1,Enum.EasingStyle.Quart,Enum.EasingDirection.Out,0,false,0)

This may help the stuttering issue? I am just trying to be helpful :slight_smile:

Heres how I solve cameras

  • I find the position the actual camera should be;
  • I see if there are any effects I want the camera to have, shaking, roll ect
  • I apply these As well as the camera’s actual position. So my camera looks something like this;

Camera.CFrame = MyCam’sCframe * MyEffectCFrame * MoreEffectCFrames

By using this method, if you add more effects, you only need to lerp that specific effect, and you’ll always have the camera remain in the same ‘position’ regardless of what you do with it.

I’d recommend instead of using this method though, creating a script in the PlayerScripts, that uses BindToRenderStep.
By doing this, you can just do a quick check every frame to see;

  • Is my player sitting?
  • if they are, here is the sitting camera function
  • if they aren’t, carry on as normal.

No need to connect/disconnet anything, and its all handled locally too.

1 Like

In case you’re still having troubles with this, check out my post that had a similar issue to yours which has recently been resolved:
https://devforum.roblox.com/t/hover-car-physics-stuttering/60801
Hope it helps you!