I’m currently working on a jojo game, and for the barrages I want to use a bezier curve to create something similar to YBA.
I tried following a few tutorials but they didn’t work, so I mixed in stuff from the forums and came up with this
local Debris = game:GetService("Debris")
local HumanoidRootPart = script.Parent.HumanoidRootPart
function lerp(a, b, t)
return a + (b - a) * t
end
function quadraticBezier(t, p0, p1, p2)
local l1 = lerp(p0, p1, t)
local l2 = lerp(p1, p2, t)
local quad = lerp(l1, l2, t)
return quad
end
while wait(1) do
local p0 = Instance.new("Part")
p0.Parent = script.Parent
p0.Size = Vector3.new(0.1,0.1,0.1)
p0.Anchored = true
p0.Position = HumanoidRootPart.CFrame * CFrame.new(0,0,3).Position
Debris:AddItem(p0,1)
local p1 = Instance.new("Part")
p1.Parent = script.Parent
p1.Size = Vector3.new(0.1,0.1,0.1)
p1.Anchored = true
p1.Position = HumanoidRootPart.CFrame * CFrame.new(-5,0,-3.5).Position
Debris:AddItem(p1,1)
local p2 = Instance.new("Part")
p2.Parent = script.Parent
p2.Size = Vector3.new(0.1,0.1,0.1)
p2.Anchored = true
p2.Position = HumanoidRootPart.CFrame * CFrame.new(0,0,-7).Position
Debris:AddItem(p2,1)
local ArmModel = script.Parent["Left Arm"]:Clone()
ArmModel.Anchored = true
ArmModel.CanCollide = false
ArmModel.Parent = workspace
Debris:AddItem(ArmModel,1)
for t = 0,1,1.5 do
local TargetPosition = quadraticBezier(t , p0.Position, p1.Position, p2.Position);
local Goal = {
Position = TargetPosition;
};
local Tween = game:GetService("TweenService"):Create(ArmModel, TweenInfo.new(1), Goal);
Tween:Play();
end
end
but the part simply goes from the arm to the starting position. I’m completely unfamiliar with bezier so go easy on me with the answers.
This is what i have: https://gyazo.com/a3110b7548cc3df785aa4a4b809018d7