When Tweening on RenderStepped there is a visible shake

Try this: instead of connecting the function to :RenderStepped, properly bind it to RenderStep with :BindToRenderStep. That way, you can set its priority.

I’m betting that your character updates at a RenderPriority of 300 (see Documentation - Roblox Creator Hub for more info), so the camera should update at a priority below that. (lower priority values get executed earlier)

RunService:BindToRenderStep(
    "camera"
    Enum.RenderPriority.Camera.Value,
    yourUpdateFunction -- this is the function you would normally connect to :RenderStepped
)
2 Likes

Nope, doesn’t work… Setting the render priority to Camera or lower has the same amount of shake and setting it as Character or above is even worse :face_with_raised_eyebrow:

Perhaps is because of how you’re updating the character?

EDIT: I would also want to know how and when you’re getting CameraFocus

The character is being updated by the core scripts, I haven’t changed them in any way :no_mouth:

CameraFocus is just the CFrame of the camera but 1 stud forward so I could make a CFrame with a Vector3 pos and Vector3 lookAt.

Yeah, after testing this for myself, it seems like Lerping isn’t the way to go if you want to eliminate stuttering. You may have to use springs.

EDIT: (I would also probably keep rotation (“look”) and position separate if I could. Use a spring for position, don’t use one for rotation.)

I’ve already been doing this with BodyGyro and BodyPosition for a while and it worked perfectly, but the problem with that is that you need to have a physical part. I haven’t used springs yet, do they need a physical part or do they only need an attachment?

I don’t mean SpringConstraints, I meant some sort of spring module.

I’ll admit that I barely know what I’m talking about at this point since I’ve only ever used springs for simulating gun recoil and not for camera interpolation. I really didn’t expect your problem to be harder than playing around with :lerp and RenderStepped priorities.

Nope. Springs still jitter.

Hey, I don’t know if this will help as I don’t see a loop in your code, but you don’t need to use loops with TweenService.

The number you put inside of TweenInfo.new should be how long the tween takes.

If it takes longer than that for some reason, Roblox will attempt to just teleport the object to the final position I believe.

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