Lerping

0

Using a method known as linear interpolation, often referred to as lerp, you can position a CFrame between two points. For instance, the following code positions the redBlock part directly between the greenCube and cyanCube parts, using a value of 0.7 to place it 70% of the distance away from the green cube.

local redBlock = game.Workspace.RedBlock
local greenCube = game.Workspace.GreenCube
local cyanCube = game.Workspace.CyanCube

redBlock.CFrame = greenCube.CFrame:Lerp(cyanCube.CFrame, 0.7)

To animate this smoothly use a loop

local redBlock = game.Workspace.RedBlock
local greenCube = game.Workspace.GreenCube
local cyanCube = game.Workspace.CyanCube

for i = 0, 1, 0.1 do
  wait()
  redBlock.CFrame = greenCube.CFrame:Lerp(cyanCube.CFrame, i)
end

  • 0 posts
  • 0 subtopics
  • 10 days ago by vince