I have seen people, use lerping for projectiles, and i would like to know how
Its a way to get from point A to point B with the amount that you want to go at. The amount would be from 0 - 1:
local A, B = Vector3.new(0, 0, 0), Vector3.new(0, 0, 10)
local Alpha = 0.5 -- this would be half of A and B
local C = A:Lerp(B, Alpha) -- This should return 0, 0, 5
Lerping is linearly interpolating from one value to another with an alpha, which is basically a number between 0-1, determining how far it should lerp to the given target point.
For example:
local position = Vector3.new(0, 0, 0)
local targetPosition = Vector3.new(0, 10, 0)
--[[
Would lerp one half of the way from position to targetPosition.
]]
local position = position:Lerp(targetPosition, .5)
print(position) --Vector3.new(0, 5, 0)
About The Alpha
The alpha value determines how far you go from one point to another or in other words, the percentage to interpolate from one pinto to another.
For example, an alpha value of .5 means interpolate 50% of the way from one point to another, .3 means 30% of the way and so on.
Keep in mind that the alpha value should be 0, 1 or a number in between them.