Problem with lerps

Hello!

I wanted to replicate tweening to make it frame dependant so i used lerps instead.

I have this script that gets ran every frame:

for i,v in pairs(workspace.Lerps:GetChildren()) do
			local object = v.Object.Value
			local fraction = v.Fraction.Value
			local goal = v.Value
			if object then
				if object:IsA("Model") then
					object:PivotTo(object:GetPivot():Lerp(goal,fraction))
					if object:GetPivot() == goal then
						v:Destroy()
					end
				else
					object.CFrame = object.CFrame:Lerp(goal,fraction)
					if object.CFrame == goal then
						v:Destroy()
					end
				end
			end
		end

The thing is the parts does not go to the location they should go.

What happens here is ever bullet turns into a point then gets added to the lerp folder but the lerp doesnt get finished properly

I would want to provide video but the site doesnt let me upload it.

Can anyone help me figure out the problem?

Lerping might not be what you’re looking for here. Lerping doesn’t smoothly interpolate as tweening does. Lerping sets the CFrame to a point in between two points. That’s what the fraction parameter is.

1 Like

Tweening is interpolation though. The tweening that we’re all familiar with (via TweenService) is a form of interpolation and parameters help configure how the alpha changes every frame starting with a given beginning and reaching a certain goal. The Lerp method only adjusts this intermediate step one time but OP has specified that this code is every frame, so it really is the same as tweening.

It’d be significantly more helpful if OP was able to provide some kind of media or an actionable test case to figure out what exactly they mean by “doesn’t get finished properly” since I don’t know if that’s in terms of the positioning being off or it doesn’t interpolate all the way or if it’s something else.

3 Likes

Store the original start position, and lerp between that and the goal. By using the object’s current position, each lerp is incrementally smaller. Also, the fraction needs to reach 1.0 in order for the object to reach its goal.

https://cdn.discordapp.com/attachments/759244287614386207/1052238098618130502/C__Users_abert_Downloads_aegis-test-place.rbxl_-_Roblox_Studio_2022-12-13_17-55-54.mp4

i cannot upload videos so i tried using a discord video link

this is what happens and when i removed the destroy if reached goal part of the code the same happened, also the lerps still exist in the lerp folder

I never said tweening doesn’t interpolate. I was saying using Lerp, in this case, would most likely be their error since lerping sets the CFrame to spot in between two points and assuming they’re not using 1 as the alpha, it most likely is the reason it’s not reaching the desired goal. It would be slightly off even if it was in a loop.

I’m not positive but I don’t think you can Lerp the PivotTo property

the points are not models so i dont think it has to do anything with the problem

its not slightly off, the fraction is 0.1 and the points stop halfway through.