How to make lerp consistent for all fps when using renderstepped

That’s the point it does nothing it just makes it .01% faster.
Some ultra low end phones will now be able to run your game at 1 more fps!!!

EDIT: As I said I can’t help with the lag issue as I don’t know what’s causing it.
I don’t think it’s the lerping that’s causing it.

So for anyone still reading this, the issue all along was the smaller offset, caused by less time between each frame, which means there is less distance when comparing the current frame to the previous frame:


therefore I multiply the current position “cccf_data.Position” with “(1/dt ) *0.02” to increasingly add more position-different as the time in between frames decreases, here is the working script that only contains the positionoffset:

local lastCameraCF = workspace.CurrentCamera.CFrame
local postionOffset = CFrame.new()

RunService.RenderStepped:Connect(function(dt)
	local camFrame = game:GetService("Workspace").CurrentCamera.CFrame
	local cccf_data = camFrame:toObjectSpace(lastCameraCF)
	
	script.Parent.HumanoidRootPart.CFrame = camFrame + camFrame.LookVector * .5 + camFrame.UpVector * .5+ camFrame.RightVector * .5
	--increase the position based on delta time to maintain the same position offset across all frame rates 
	local targetCFrame = CFrame.new(cccf_data.Position*(1/dt)*0.02/6)
	
	postionOffset = postionOffset:Lerp(targetCFrame,6*dt)

	script.Parent.HumanoidRootPart.CFrame = workspace.CurrentCamera.CFrame * postionOffset
	--updates the previous position for the next frame
	lastCameraCF = workspace.CurrentCamera.CFrame
end)

There is still a tiny bit off lag when using a snappy lerp at higher fps, so if anyone has a suggestion for how to resolve that please reply…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.