Something like this is actually pretty simple to do. You will need to know a bit of maths though.
You can integrate to get from Velocity to Position. (Calculus)
Since you know the Velocity of a Part you can simply “keep going” and just keep stepping forward. E.g.
local futurePosition = table.create(5,Vector3.new())
local futurePredctions = 5 -- How far into the future we go
local DeltaTime = 1 -- this is the amount of time before we "plot" another point. Smaller values give you a smoother curve
-- we will predict 5 seconds into the future with each prediction being 1 second apart
local Velocity = Part.AssemblyLinearVelocity -- Get parts Velocity
for i = 1, futurePredictions do
futurePosition[i] = Part.Position + (Velocity * i)
end
This piece of code will give us a Future prediction of where a part will be given its current Velocity.
You will notice however that the predictions are a straight line. That’s because you will need to take into account acceleration too.
It really depends on how you calculate the acceleration first. The most accurate way is to simply store the previous two Velocities and then simply get the difference. For example.
local V1 = Part.AssemblyLinearVelocity
local Accel = Vector3.new()
local V0 = V1
RunService.Heartbeat:Connect(function(deltaTime)
V1 = Part.AssemblyLinearVelocity
Accel = (V1 - V0)/deltaTime
V0 = V1
end)
This piece of code gets the Acceleration of a part each frame.
Or if your projectile will not have a changing acceleration then you can simply get the worlspace.Gravity
and then turn it into a downward Vector.
Then instead of having a constant Velocity update the Velocity each Prediction with the deltatime you are using.
local Velocity = Part.AssemblyLinearVelocity -- Get parts Velocity
for i = 1, futurePredictions do
futurePosition[i] = Part.Position + (Velocity * i)
Velocity += Acceleration * DeltaTime
end
If you don’t need precision then this solution probably isn’t for you however. Hope this helps.