I was trying to make a DB Energy Attack thing, where it spams a lot of little projectiles to the Mouse.Hit.Pos, and they go in arc motion using Bézier.
At first glance, looks good
But when I use it pointing to a distant objective, the speed is like this:
On those gifs I use this script
local function TweenKi(Arm,FinalP,EffectsFolder)
task.spawn(function()
local rnd = Random.new()
local rndCF
local StartCf
if Arm.Name == "Left Arm" then
rndCF = CFrame.new(rnd:NextInteger(-6,-3),rnd:NextNumber(-4.5,4.5),rnd:NextNumber(-5,-6))
StartCf = Arm.CFrame * CFrame.new(-1,0,-5)
elseif Arm.Name == "Right Arm" then
rndCF = CFrame.new(rnd:NextInteger(3,6),rnd:NextNumber(-4.5,4.5),rnd:NextNumber(-5,-6))
StartCf = Arm.CFrame * CFrame.new(1,0,-5)
end
local TimePassed = 0
--Ki Blast:
local KiBlast = MeshesF.KiBlast:Clone()
KiBlast.Parent = EffectsFolder
KiBlast.CFrame = StartCf
Debris:AddItem(KiBlast,DebrisT)
--
local MiddlePoint = StartCf * rndCF
local Speed = 1
local Duration = (StartCf.Position - FinalP).Magnitude / Speed
local tweenDelay = task.wait()
TimePassed = 0
while TimePassed < Duration do
local TimeRunning = TimePassed / Duration
local pointAtTimePassed = Bezier_Module:QuadraticBezier(TimeRunning,StartCf.Position,(MiddlePoint).Position, FinalP)
TimePassed += Speed
local tween = TweenS:Create(KiBlast,TweenInfo.new(tweenDelay),{CFrame = CFrame.new(pointAtTimePassed)}):Play()
task.wait(tweenDelay)
end
end)
end
I’ve used a for i = do loop, and another script that also uses tweening, but the problem is almost the same but the further away the objective is, the faster it goes, and the closer it is, the slower it moves.
What you want to achieve?
I want the projectiles to move to the Mouse.Hit.Pos, traveling at the same speed regardless the Mouse.Hit.Pos distance, and going in arc motion. But I have no clue on how to do that.