teleport and lerp() are disqualified cus teleport is not travelling in a technical perspective(i am a spacial tracking fan) and lerp() is basically teleport if u think abt it. So far i find the best method is relating the distance between the start and end points of the projectile's course with its velocity; and the much more easy bodyposition. But are there any better ways?
what is the best way to make a projectile always travel to any location in a fixed amount of time?
1 answer
To do this, I would use TweenService. Get the CFrame info of the target part, like this:
local TargetPos = {CFrame = workspace.Target.CFrame}
First make sure the target part and the projectile are both Anchored. Then create the tween information for projectile like this.
local tweeninfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Inout, 0, false, 0)
The above code creates the info for the Tween, which says that the projectile will travel to the target in 0.5 seconds without any smoothing (easing). Also make sure you actually create and play the tween, from the server side.
local TService = game:GetService("TweenService")
TService:Create(workspace.Projectile,tweeninfo,TargetPos)
Your final code should be:
local Target = {CFrame = workspace.Target.CFrame}
local tweeninfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Inout, 0, false, 0)
local TService = game:GetService("TweenService")
local tween = TService:Create(workspace.Projectile,tweeninfo,TargetPos)
tween:Play()
There are other ways of tweening parts but this is usually how I do it. Hope this helped. If I got something wrong please leave a comment since I'm just writing this off the top of my head around midnight.
3 comments
oof. Well im sorry to have wasted ur time but tweenservice is also just segmented teleporting, like lerp(). Its late in night, i dont blame u, but if u did read the guidelines i did mention anything related to teleporting would not be counted as i want the projectile to completely cover its course, if u know what i mean.
but thanks for trying
It's fine, don't worry about it.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
lol