NinjoOnline
(NinjoOnline)
#1
I’m wanting to create points between 2 Vector2 positions, for example
local A = Vector2.new(2, 2)
local B = Vector2.new(10, 10)
-- create 4 points evenly spaced between these 2 points
for i = 1, 4 do
end

I know doing
(A + B) / 2
Gives the centre point, but I’m unsure how to actually get a specific number of points and placed spots at each point
serverIess
(serverIess)
#2
You could achieve this in a similar way to a lerp.
a + (b - a) * alpha
Where alpha is the percentage of the way to the final point.
2 Likes
NinjoOnline
(NinjoOnline)
#3
Would that create a point on position B say? As I am manually creating points for A and B
serverIess
(serverIess)
#4
If you do something like the following then it will not create a point at vector b.
local a = Vector2.new(0, 0)
local b = Vector2.new(100, 100)
local points = 4
for i = 1, points do
print(a + (b - a) * i / (points + 1))
end
-- 20, 20
-- 40, 40
-- 60, 60
-- 80, 80
2 Likes