Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Lerp and CFrame help needed + Question?

Hello guys i need help for Lerp or CLerp and yes i have read the wiki but i cant seem to understand it

So my question is

How do you Clerp a Motor6D C0 C1

Heres how'd you do it in CFrame

ExampleMotor6D.C0=CFrame.new(0,0,0,0,0)--you get the point

How would i do that in lerp? or Clerp?

and please explain because im a slow learner =/

1 answer

✓ Accepted answer

You should already know that Lerp means linear interpolation.

The lerp function works like this.

C0 = C0:lerp(CFrame, Alpha) -- Alpha is a range from 0, 1
-- Basically you tell it the CFrame that you want to set(The first C0), the starting position(The second C0), and the ending position(CFrame) and Alpha, the percentage to move.


-- Here is an example

local Start = CFrame.new(0,0,0)
local End = CFrame.new(0, 0, 10)

print(Start:lerp(End, 0.5).p)
-- This should print something like (0,0,5)

I'm just going to take a guess and say, you want this for animating. Whether to animate players or parts I don't know.

-- An example of how this can be put to use.

local Part = Instance.new("Part", workspace)
Part.CFrame = CFrame.new()

for i = 0, 1, 0.05 do
	wait()
	Part.CFrame = Part.CFrame:lerp(CFrame.new(0, 0, 10), i)
end

Hope this helps. I wrote this entire thing in the answer box so if it errors or doesn't work let me know.

3 comments

0

so to lerp i just do CFrame:lerp(CFrame.new(allmyusualystuff),number)?

0

Pretty much but you missed a part. You still need to set the cframe you are trying to change. CFrame = CFrame:lerp(YourCFrame,number)

0

ok thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.