I've made a script that was supposed to launch the sphere to a target with a curved motion. However, it didn't give a satisfying result :
https://gyazo.com/838f93e844708207f648f82b1c853279
(And here's what i was looking for : https://gyazo.com/82b8b7ffdd6486f15c3958bc913a6154 )
As you can see, there are 2 spheres : a red one (the target) and another one (the projectile) I wanted to take the distance between the two spheres and divide it into 12 points, points the projectile would follow to reach the target so its in a curved motion (forgive my english pls).
Here's the script :
local TweenService = game:GetService("TweenService")
local pos1 = script.Parent.Position
local pos2 = game.Workspace.Target.Position
local tweenInfo = TweenInfo.new(
0.1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In
)
local lerpValue = 0
local vectorValue = 0
for i=1,6 do
lerpValue = lerpValue + 0.075
vectorValue = vectorValue - (2 - i/1.5)
local point = pos1:Lerp(pos2, lerpValue)
local tween = TweenService:Create(script.Parent, tweenInfo, {Position = point + Vector3.new(0,0,vectorValue)})
tween:Play()
wait(0.1)
end
for i=1,6 do
lerpValue = lerpValue + 0.075
vectorValue = vectorValue + (2 - i/1.5)
local point = pos1:Lerp(pos2, lerpValue)
local tween = TweenService:Create(script.Parent, tweenInfo, {Position = point + Vector3.new(0,0,vectorValue)})
tween:Play()
wait(0.1)
end
local tween = TweenService:Create(script.Parent, tweenInfo, {Position = pos2})
tween:Play()
Note : I'm not a pro so if you could find an "easy" or "easily understandable" way to get the result i want, it would be great

1 comment
Bézier curves