Currently in my game, players can use a tool to place pillars, once 2 pillars are placed it creates a wall. The idea is to claim land by walling off portions of the land.
I'm trying to figure out a way that once a completed area is walled in it would "Claim" that land for the player that built the walls. "Claim" going as far as just getting a numerical value for the amount of land you walled in.
Any articles/docs or just thoughts on this would be helpful.
Thanks for any help!
EDIT: Wondering if a grid system like this would be too laggy because of creating so many parts
local base = game.Workspace.Baseplate
base.Transparency = 1
local model = Instance.new("Model", game.Workspace)
model.Name = "Grid"
for i = 1, 50, 1 do
for j =1, 50, 1 do
local part = Instance.new("Part", model)
part.Name = i..", "..j
part.Anchored = true
part.Size = Vector3.new(8,0.25,8)
part.Position = Vector3.new(i*8, 0.125, j*8)
end
end

7 comments
You could create a Region3 by using the farthest extents of the walls and go from there
Although that would only work effectively if the enclosed area had two sets of parallel sides
Hmm, yeah any completed "room" could be any number of shapes. I appreciate your thoughts though. I'm stumped atm
If you're using a grid-based system, you could try a flood-fill algorithm.
id like to rephrase gioni01's comment by saying that a region3 only works for rectangles, not all parallelograms
Thank you
@RubenKan, Flood-fill looks like a good choice, How would i identify when a walled off area is completed?