How to make a part curve to its destination?

Just making some effects, zero clue how to do this though as it’s uncharted territory for me.

I tried a simple part to move forward to its destination, with this code:
game.ReplicatedStorage.SS.OnServerEvent:Connect(function(Player)
local Position = Player.Character.HumanoidRootPart.Position
local LookVector = Player.Character.Head.CFrame.lookVector

local Orb = Instance.new("Part")
Orb.Parent = workspace
Orb.Anchored = true
Orb.Material = Enum.Material.Neon
Orb.Color = Color3.fromRGB(131, 216, 255)
Orb.Shape = Enum.PartType.Ball
Orb.CFrame = CFrame.new((Position) + Vector3.new(5, 8, 8))
game.Debris:AddItem(Orb, 5)

local OrbFire = game.TweenService:Create(Orb, TweenInfo.new(3), {
	CFrame = CFrame.new(LookVector * Vector3.new(8,8, 250))
})
OrbFire:Play()

end)

However, for some reason it wasn’t accurate at all (sorry, once again this is uncharted territory for me)
Thanks in advanced!

1 Like

You learn parabolic functions.

y = ax^2 + bx + c

replace y with the desired y coordinate or Z coordinate of the curve or maybe the cross product idk.

But I’d go with learning parabolas

1 Like

Bezier curves should be the answer, you generate a curved path between two positions.

Very interesting, I never knew about that so I’ll certainly do some research behind it, thanks

Here is a test with a quadratic bezier using Math++ - Roblox

Mathpp = require(game.ReplicatedStorage["Math++"])

game.ReplicatedStorage.SS.OnServerEvent:Connect(function(Player)
local Position = Player.Character.HumanoidRootPart.Position
local LookVector = Player.Character.Head.CFrame.lookVector

local Orb = Instance.new("Part")
Orb.Parent = workspace
Orb.Anchored = true
Orb.Material = Enum.Material.Neon
Orb.Color = Color3.fromRGB(131, 216, 255)
Orb.Shape = Enum.PartType.Ball
Orb.CFrame = CFrame.new((Position) + Vector3.new(5, 8, 8))

game.Debris:AddItem(Orb, 5)

local p1 = Orb.CFrame.p
local p3 = CFrame.new(LookVector * 250).p
local p2 = Vector3.new(((p1+p3)/2).X, p1.Y, ((p1+p3)/2).Z)
for i = 0, 1, 0.01 do
	Orb.Position = Mathpp.quadBezier(i, p1,p2,p3)
	wait()
end

end)

this is what a quadratic bezier looks like
tGeJC

2 Likes

That’s extremely cool! Thanks, I tried that out and works pretty perfect! Thank you once again for the information!

1 Like