Room detection system

if you want to make it working when you place wall cal function rec with wall as parametr and if you want to make 1 wall as wall of 2 rooms (room1|room2) you must set parent of clone (wall:Clone().Parent at place of wall.Parent)

Ok I will try to fix it tomorrow I am +1 and it is late

1 Like

ok i thinked about this and i have solution, but first lets find the bad line:

for v, wall in pairs(WALLS) do

rec(wall)

end

this will do regroup for every wall so i regroup the left wall first and it will auto regroup the middle one and the right and than the problematic line will call regroup of the middle one, that have grouped wall on both sides so you must add your place mechanism to it and remove the walls and it can work than

Hmm…

Ok…welll i think i started undestanding but idk

1 Like

Because post limit, i needed to solve it by private messaging with @Imaginze and here is game i made that will detect rooms

1 Like

Expanding on the pathfinding idea:
Just detect positions betweens nodes, and try to see if pathfinding can get out of it. If it can’t, it’s closed. If so, it’s open.
I think that’s what people are trying to get to, not sure tho :wink:

That’s a brilliant and creative solution! :smile: It’s also exactly how a really basic maze solving algorithm works too. Follow one edge and eventually you’ll end up at the exit where there are no more edges. If you reach the first edge it must be a closed loop, meaning a room!

In fact, I wonder if all solutions to this problem are maze solving algorithms, and vice versa? :thinking:

My solution is regrouping the walls to models and when I place wall and there are 2 walls from same model touching it, it must be connected on other side so it must be room

I already made this by regrouping walls to model

A post was merged out for bumping.