Help with CFrame.lerp Motor6Ds or Welds?
I need an understanding of how I should go about welding an object animation using lerp.
This is my overall script.
01 | PartToWeldTo = game.Workspace.PartToWeldTo |
02 | GhostPart = game.Workspace.GhostPart |
03 | MovingPart = game.Workspace.MovingPart |
05 | local PartWeld = Instance.new( "Motor6D" , PartToWeldTo) |
06 | PartWeld.Part 1 = GhostPart |
07 | PartWeld.Part 0 = MovingPart |
08 | PartWeld.C 1 = GhostPart.CFrame |
09 | PartWeld.C 0 = MovingPart.CFrame |
12 | game:GetService( 'RunService' ).RenderStepped:Connect( function (Step) |
14 | PartWeld.C 0 = PartWeld.C 0 :lerp(PartWeld.C 1 , Step) |
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.