When Tweening on RenderStepped there is a visible shake

This happens when the physics sim and your interpolation code use different time deltas.

Try using the delta from Stepped instead of RenderStepped.

3 Likes

Where do I put the delta? I’ve changed RenderStepped to Stepped and also tried Heartbeat but it came up with the same results.

You know when you lerp you have a value you keep adding to? Add delta to that instead of whatever else you’re adding.

Instead of what I suggested earlier:

local alpha = 0.5 -- A value between 0 and 1. 1 is instantaneous. 0 doesn't move at all.
Camera.CFrame = Camera.CFrame:lerp(goal, alpha)

Multiply the alpha by the dt. Increase alpha by some factor because we’re multiplying it by 1/60 on average. Also clamp it to between 0 and 1 so that it never overshoots when the framerate drops suddenly.

local alpha = math.clamp(0.5 * 60 * dt, 0, 1) -- dt goes here
Camera.CFrame = Camera.CFrame:lerp(goal, alpha)

So this works fine, except I can’t change the alpha to a lower number for some reason and the character still jitters when jumping… :rage:

https://i.gyazo.com/32cdda5b6c1f134357dc700ba59d136f.mp4

The alpha is always 1:

image

I tried it with Heartbeat which gave a variable alpha, but it still jittered.

Edit:

Figured out I can change the alpha by dividing it, but it still has a jitter…

Edit2:

Better gif

https://i.gyazo.com/5295d20e14e162fe69bcf9aa9cfd8bc9.mp4

If you’re using Stepped, then make sure you’re using the second parameter instead of the first one. The first parameter is the time since the game started, the second one is the actual dt.

(it would also help if we could see the code you have so far!)

So your solution currently works the best, there is none to very little jitter on low alpha values, but the higher I go the more jitter there is :face_with_raised_eyebrow: I want to use about 0.35-0.4 alpha because anything lower is too unresponsive, but that kind of alpha produces a lot of jitter. Here is my whole loop

game:GetService("RunService").Stepped:connect(function(first, dt)
		--If character exists
		if Character then
			--Set rotated start cframe inside head
			local startCFrame = CFrame.new((rootPart.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, cameraYAngle, 0)*CFrame.Angles(cameraXAngle, 0, 0)
			
			--Set camera focus and cframe
			local cameraFocus = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(3.5,0,-50000))
			local cameraCFrame = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(3.5,0,7.5))
			 
			--Lerp
			local alpha = math.clamp(0.35 * 60 * dt, 0, 1)
			local current = Camera.CFrame
			local goal = CFrame.new(cameraCFrame.p,cameraFocus.p)
			Camera.CFrame = current:lerp(goal, alpha)
		end
	end)

I’m at a loss on what to do.

1 Like

Same :disappointed_relieved:

I tested it out on an old game of mine and the only thing that seems to be shaking is the player itself, as seen here: https://i.gyazo.com/e8f96239a3041475e12f5b3dd01b03b7.mp4
The video might not show it very well but the only thing that is shaking is the player

Edit: This could be related to Hover car physics stuttering?

It’s definitely the camera not the player, the player is the closest thing to the camera which the camera follows thats why it seems like it’s just the player jittering.

1 Like