Hello there, im trying to make parts curve with bezier curves and move to destination with random spread.
The problem is, because i set the random offset on X axis, when i turn 90 degrees right which makes me match up with the X axis, parts does not spread anymore.
Basically, i know the problem but not the solution.
Videos of what im talking about:
1- How it should work
https://gyazo.com/859cb9f0169c4a2ab85eb5540433e2ff
2-How it works when i turn right
https://gyazo.com/d810b619ba6946abbc92798daa7613ba
As you can see it goes in a straight line.
My code:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, mouseP)
local hrpp = player.Character.HumanoidRootPart.Position
local endp = mouseP
local offset = Vector3.new(math.random(-20,20),math.random(-10,10),0)
local mid = (hrpp + endp)/2 + Vector3.new(0,40,0) + offset
local part = Instance.new("Part",player.Character)
part.Size = Vector3.new(2,2,5)
part.Anchored = true
part.CanCollide = false
for i= 1, 50 do
local t = i/50
local q = quadBezier(t,hrpp,mid,endp)
part.CFrame = CFrame.new(q)
part.CFrame = CFrame.new(q,quadBezier(t + 0.1,hrpp,mid,endp))
wait()
if i == 50 then
part:Destroy()
end
end
end)