I’m making a mine spawner for my game. I want the mine to spawn along the mob path.
To track the path I placed points
in every tile within the spawners radius, checking for the path waypoints
.
I do this using the following script:
Summary
local corners = tower:WaitForChild("Corners")
for i, point in ipairs(waypoints:GetChildren()) do
local distance = (point.Position - position).Magnitude
if distance < maxRange then
-- if point is with 1 stud of corner, add it to the list
for _, corner in ipairs(corners:GetChildren()) do
local cornerDistance = (point.Position - corner.Position).Magnitude
if cornerDistance <= 5 then
table.insert(points, point.Name)
table.insert(points, point.Position.X)
table.insert(points, point.Position.Y)
end
end
end
end
print(points)
I know I can use Lerp
to randomly spawn the mines between two points but;
I basically need to know if there is a way to loop each points X and Z value through every other points, find the 2 furthest points and where they intersect, and then spawn a mine randomly along those lines.