so i need some help with bezier curves. I just learned them like 20 minutes ago so I’d figure I’d try and experiment with them, so i tried doing a test to make a barrage similar to like yba or some other games, but I noticed that the parts are kind of not moving with the player.
local function lerp(a, b, t)
--a value is start position
--b value is end position
--t value is time
return a + (b-a) * t
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local finishpoint = Instance.new("Part")
finishpoint.Name = "FinishPoint"
finishpoint.Parent = character
finishpoint.CanCollide = false
finishpoint.Anchored = true
finishpoint.Size = Vector3.new(0.5,0.5,0.5)
local curve = Instance.new("Part")
curve.Name = "CurvePoint"
curve.Parent = character
curve.CanCollide = false
curve.Anchored = true
curve.Size = Vector3.new(0.5,0.5,0.5)
task.spawn(function()
while task.wait(0.01) do
finishpoint.CFrame = character.Torso.CFrame * CFrame.new(0,0,-5)
curve.CFrame = character.Torso.CFrame * CFrame.new(3,0,-2.5)
end
end)
local x = 0
repeat
local startpoint = character.Torso.Position
local endpoint = character.Torso.CFrame * CFrame.new(0,0,-5)
local endp = endpoint.Position
local curvepoint = character.Torso.CFrame * CFrame.new(3,0,-2.5)
local curvep = curvepoint.Position
x += 1
local LeftArm = character["Left Arm"]:Clone()
LeftArm.Name = "LeftArmBarragePart"
LeftArm.Parent = character
LeftArm.CanCollide = false
LeftArm.Anchored = true
for i = 0, 100, 1 do
local t = i/100
local l1 = lerp(startpoint, curvep, t)
local l2 = lerp(curvep, endp, t)
--lerp1.Position = l1
--lerp2.Position = l2
local quad = lerp(l1, l2, t)
LeftArm.Position = quad
task.wait(0.01)
end
until x == 100
end)
end)
currently my script just defines the end point of the curve, but it doesn’t change as the player moves. So that has me wondering if its possible to move a bezier curve as a lerp is playing so that the parts that are lerping actually move with the curve. Is this possible?