So i made my first Quad Bezier Curve right, and i realised that if the enemy will move while my part is flying to it, then it won’t get to him because the “finish” position i set at the start isn’t updating, so the part is flying to where he was when i used module.
The module:
function quadbeziercurve(a,b,t)
return a+(b-a) * t
end
local module = {
["Createquadbezier"] = function(enemychar,whattodo,mean, sound, needtorotate,start,finish,t,target,p1)
for i = 0,10,t do
local t = i/10
local l1 = quadbeziercurve(start,p1,t)
local l2 = quadbeziercurve(p1,finish,t)
local quad = quadbeziercurve(l1,l2,t)
target.CFrame = CFrame.new(quad)
wait()
end
end
you should do the loop out of the function and just call for each point that way you are updating the end position each time its called. something like below and just send updated end pos each time
for i = 1 , Points do
local EndPosition = HumanoidRootPart.Position -- update..
local NewPosition = quadBezier(i/Points, StartPos, MidPosition, EndPosition)
end
for i = 1,10,0.5 do
wait(0.1)
game.ReplicatedStorage.CreateRemote:FireAllClients(enemychar,"Createquadbezier",nil,nil,nil,spike1.Position,enemychar:FindFirstChild("HumanoidRootPart").Position,1,spike1,to)
end```
I just have to play with numbers now
yeah with the above example you are just requesting each point as it is needed and updating the end position which is probably the one that has changed Mid can also but you can get a mid position between your start and end each time
if enemychar ~= nil then
delay(0,function()
game:GetService("RunService").Heartbeat:Connect(function()
finish = enemychar:FindFirstChild("HumanoidRootPart").Position
end)
end)
end
So i just updated finish position like crazy and it worked .-.
np also I would tween the returned position and it should make it smoother depending on what your using
you may also think about using it in combination with a AlignPosition or something