# Can somebody please define "Lerp()" for me?

I am in need help of the “Lerp()” function,
I do not understand what Lerp() means.
I have tried watching videos, but I still don’t understand.
Can somebody please define “Lerp()” for me.

You have 2 CFrames. Lerp is the percentage of movement. Lerp(1) will go to the final CFrame. Lerp (0.5) will go halfway. Lerp (0.3) will go a third. It’s like tween, but you specifically choose where the CFrame will stop. Let’s say you want to go halfway, on tween you’d have to calculate the midway positition. Lerp you can just use Lerp(0.5). Tween works for any value, Lerp only for CFrame

Note, I haven’t used Lerp in a long time so I don’t remember if you actually put the value like that.

Edit: Just checked and usage is CFrame1:Lerp(CFrame2, percentage)

Lerp is a function which allows you to interpolate on a straight line between 2 values. It’s used mostly when creating Bezier curves, which allows you to draw curves around certain points

What about like Lerp(CFrame * 0.5) ??

Lerping is interpolating two values on a specific alpha.

For example X = 5, Y = 12.

If I lerp between these two with an Alpha = 0.5, it will result in a value halfway between them, i.e 8.5.

Same way if I lerp it Alpha = 0.25, it will result in a value a quarter way between them, i.e 6.75.

This is the formula of lerping:
`Start + ( ( End - Start ) * Alpha )`

For example I’m trying to make a gun sway for an fps, I want it to sway 0.05 seconds after the camera is turned.

`:Lerp()` is a built in function of both Vector3 and CFrame. The use case is to return a point located between two points (Vector3 or CFrame) dependent on the Alpha value given. Alpha is just a fancy number range that is between 0 and 1.

``````local StartPosition = Vector3.new(1,0,1) --We define a point at 1,0,1

local EndPosition = Vector3.new(1,0,3) --We define another point at 1,0,3
``````

Now saw we wanted to find some point that is a quarter of the distance from the starting position to the end position. This is where Lerping could come into use.

``````local QuarterDistance = StartPosition:Lerp(EndPosition,0.25)
``````

We take the Vector3 value where we start, use the end position as a goal Vector3, and then define a value between 0 and 1 on how far into that distance between the two points we must go until returning a value.

6 Likes

Oh okay I get it now.
Characters