The only problem that i’m facing is how i should do map generation, because i want it to be random, but have an exit. Also players should be spawning random on the map. How would I approach this?
For the map generation I have no idea, but the game looks good! For player spawning make the generation script put a spawn point in every room or so. Good work!
A “plot” refers to everything within the black squares.
The plots will be randomly generated from existing rooms, each with four exits/entrances to prevent players from getting stuck.
As mentioned by owee814, every generated plot will have one spawn point so that players will spawn randomly on the map.
This is the idea I’m using. And now, it’s coding time!
(In a script)
local plots = require(script.Plots)
for x=0, 500, 50 do
for y=0, 500, 50 do
plots.Generate(x, y)
task.wait(.1)
end
end
The “plots” variable refers to a ModuleScript in the script.
(ModuleScript)
local plot = {}
plot.random = Random.new()
local rs = game:GetService("ReplicatedStorage")
function plot.GetRandom()
local possplots = rs:WaitForChild("PossiblePlots"):GetChildren()
local randomplot = possplots[plot.random:NextInteger(1, #possplots)]
return randomplot
end
function plot.Generate(x, y)
local randomplot = plot.GetRandom()
if x == 300 and y == 300 then
randomplot = rs.ExitPlot
end
local newplot = randomplot:Clone()
local cframe = CFrame.new(x, 0, y) -- 0 is the y-level in the 3 space, change this if you want
newplot:PivotTo(cframe)
newplot.Parent = workspace:WaitForChild("GeneratedPlots")
return newplot
end
return plot