Some help with Lerping

Does an object need to be anchored/unanchored for lerping?

Linear interpolation, or Lerp, simply returns a new value in between the given CFrame and the goal CFrame. For example, if you did something like this:

PartCFrame = workspace.Part.CFrame
GoalCFrame = PartCFrame*CFrame.new(0,10,0)
workspace.Part.CFrame:Lerp(GoalCFrame,.5)

it would return a CFrame value equal to PartCFrame*CFrame.new(0,5,0) because the second parameter of Lerp was .5

Lerp simply returns a new CFrame value, and will not move an object. If you want to use Lerp to move an object set the CFrame of the part to the Lerped CFrame. (would not matter if anchored since you are just setting the CFrame)

1 Like

You also can use a ‘tweening’ motion for lerping.

Example:

local part = script.Parent
local TargetPart = game.Workspace.TargetPart

for i = 0,1,0.1 do -- 0 to 1 is the percentage of the way the part lerps to, example: 0.7 = 70%
    wait()
    part.CFrame = part.CFrame:Lerp(TargetPart.CFrame,i)
end
1 Like