How to make lerp consistent for all fps when using renderstepped

WHY IS EVERYONE HERE JUST MULTIPLYING BY DELTA TIME???

That is not how it should be done it should be done like this:

1-mult/(dt+1) -- the 1- can be removed if you swap the ordering of the vectors you're lerping.

EDIT: Some things need to be multiplied by delta time some things don’t other things need multiplying in more advanced ways.

It’s bad, you shouldn’t use it inside render stepped because it will crash!

uhhh, i believe he wants to lerp by time, but he don’t know how to do it for all FPS settings, repeat loop solution is the best one as it allows you to lerp using time

Also correction for lerps

Pos1:Lerp(Pos2, 1/Time) -- I forget to turn time into percents

What I just put in that sample does what he wants it makes it lerp more on low fps and more on high fps and never lerps by more than 1 and never below 0 unlike a simple multiplication.

yk, i don’t use multiplication either, adding Time until t’s 1 or more is the only way really, i don’t know your solution but if it works then it’s good too

1 Like

this didn’t work 1-mult/(dt+1) or mult/(dt+1), it was just laggy and the positions was still lower for higher fps.

I’m trying to understand how to implement your solution in my script but I guess I still doing something wrong:

local Time = 0
repeat
	Time += RunService.Heartbeat:Wait() 
	local camFrame = game:GetService("Workspace").CurrentCamera.CFrame
	local cccf_data = camFrame:toObjectSpace(lastCameraCF)
	
	script.Parent.HumanoidRootPart.CFrame = camFrame + camFrame.LookVector * 0.5 + camFrame.UpVector * 0.5 + camFrame.RightVector * 0.5

	local lower_offset_effect = 0
	local targetCFrame = CFrame.new(cccf_data.Position / (6 + lower_offset_effect))
	print(targetCFrame)
	
	
	postionOffset = postionOffset:Lerp(targetCFrame, 1 / Time)

	script.Parent.HumanoidRootPart.CFrame = workspace.CurrentCamera.CFrame * postionOffset

	lastCameraCF = workspace.CurrentCamera.CFrame
until Time >= 1

oh wait I realized that I did something else in the script wrong

1 Like

I have fixed the other issue but the script above still doesn’t seem to do anything, so how should it be implemented?

I just tested myself and yeah I got it wrong here the correct version:

1-1/(dt*mult+1) -- the 1- can be removed if you swap the ordering of the vectors you're lerping.

Using 1-1/(dt*mult+1) gives a smooth lerp but, for this viewmodel it has to be snappier, so I’m using:
(1-1/(dt*mult+1))*16 but the it lag more and using any of these as a alpha value still makes the position offset lower for higher fps.

Multiply the mult by 60 or something near and it will look normal don’t multiply outside of the innermost brackets please. I excluded the multiply by 60 so you don’t add a unnecessary multiplication since you can just muliply your mult values whilst writing the script instead of zapping performance on it every single frame.

so like this instead? 1-1/(dt*60*mult+1)

1 Like

That will work just bake the multiplication in instead of doing it at runtime, you will have to make adjustments anyway.

What do you mean by baking the multiplication in?
Cause at the moment multiplying with a higher value makes it laggyer but snapppier:
postionOffset = postionOffset:Lerp(targetCFrame,1-1/(dt*60*mult+1))

I mean if mult is 0.1 you would make it 6 instead of adding *60 into the script.

this still makes it laggy: 1-1/(dt*60*+1)

it only saves microseconds of performance it’s just to save a tiny amount of speed that could be used elsewhere.

I don’t know why it’s laggy so I can’t help with that but it should stay consistent now instead of being a different distance depending on framerate.

EDIT:

Also you have a * immediately followed by a + nothing in between why???
I mean’t like this:

local mult = 6
1-1/(dt*mult+1)

as opposed to:

local mult = 0.1
1-1/(dt*60*mult+1)

I tried that now but it give the same result

Edit: Like it doesn’t fix the lag when trying to have the lerp snappier