Help with bezier curve

I already have the curve done (the quad berzier function is not mine) and i would like to know how to make the boomerang range bigger, i have some knowledge about the curve but i have no idea how to make the range larger…

local hasammo = true
local ss = game:GetService("ServerStorage")
local coins 
local parts = 0
local chrp = nil
local chrcf = nil
local p0 = nil
local p1 = nil
local p2 = nil
local player
function bezierdraw(pos)
    local Cube = Instance.new("Part")
    Cube.Size = Vector3.new(0.4,0.4,0.4)
    Cube.Position = pos
    Cube.Transparency = 0.2
    Cube.Anchored = true
    Cube.CanCollide = false
    Cube.Name = "beziertest".. player.Name
    Cube.Parent = workspace
end
function quadBezier(t, p0, p1, p2) -- function from article page lol
    return (1 - t)^2 * p0 + 2 * (1 - t) * t * p1 + t^2 * p2
end
script.Parent.OnServerEvent:Connect(function(plr, hit, campos, pos, CfrmHit)
    player = plr
        coins = plr.leaderstats.Coins.Value
        if hasammo == true then
        hasammo = false
        if plr.Character ~= nil then
            local Boomerang = script.Parent.Parent.Parent.Handle:Clone()
            p0 = plr.Character.PrimaryPart.Position
            Boomerang.Position = p0
            Boomerang.Anchored = true
            Boomerang.Parent = workspace
            p1 = Vector3.new(hit.X,hit.Y,hit.Z)
            p2 = Vector3.new(plr.Character.PrimaryPart.Position.X+1,plr.Character.PrimaryPart.Position.Y,plr.Character.PrimaryPart.Position.Z)
            for t = 0, 1, .01 do -- do a for loop from 0 to 1
                p2 = plr.Character.PrimaryPart.Position
                Boomerang.Position = quadBezier(t, p0, p1, p2) -- call the quadratic bezier curve function and place the new part
                bezierdraw(quadBezier(t, p0, p1, p2))
                game:GetService("RunService").Heartbeat:Wait(0) -- wait a bit
            end
            for _, des in workspace:GetDescendants() do
                if des.Name == "beziertest".. plr.Name then
                    des:Destroy()
                end
            end
            Boomerang:Destroy()
            hasammo = true
        end
        end
end)

ignore some variables… i have redone the script too many times

1 Like

Maybe use a cubic bezier curve instead of a quadractic one. Which takes about 4 points, you can do the same for point 1 and point 2, point 3 ahould probably be 60 degrees rotated from the throwing thing, and 4 would be the player position.

I am not on my pc right now. So this is just some instructions to try.

1 Like