Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Help with CFrame.lerp Motor6Ds or Welds?

Asked by 7 years ago

I need an understanding of how I should go about welding an object animation using lerp.

This is my overall script.

01PartToWeldTo = game.Workspace.PartToWeldTo
02GhostPart = game.Workspace.GhostPart
03MovingPart = game.Workspace.MovingPart
04 
05local PartWeld = Instance.new("Motor6D", PartToWeldTo) -- These couple of lines are where I'm struggling at.
06    PartWeld.Part1 = GhostPart
07    PartWeld.Part0 = MovingPart
08    PartWeld.C1 = GhostPart.CFrame
09    PartWeld.C0 = MovingPart.CFrame
10 
11 
12game:GetService('RunService').RenderStepped:Connect(function(Step)
13    wait()
14    PartWeld.C0 = PartWeld.C0:lerp(PartWeld.C1, Step)
15end)

My lerp seems to function well, however, after assigning the C0 to the MovingPart, it instantly offsets my MovingPart to the world position of (0, 0, 0). It then lerps from that position to my PartToWeldTo.

I'm not sure how C1, C0, Part1, or Part0 work with one another. My goal is to allow a lerping animation to take place (from my MovingPart's initial position to my GhostPart's position), while my PartToWeldTo is moving.

This lerp also includes a rotation, respectively inside of the C1's CFrame. The lerping takes place appropriately while the PartToWeldTo is moving, with a strange initial offset.

Answer this question