- Home /
Is there a basic tutorial on building rooms and walls (like in the sims)
Hi! I can't believe how hard this is, even though I'm not new to Unity, but I'm hitting a major brain block here.
I want a basic system where:
a user clicks a point on a grid and release somewhere else, creating a wall. (not too difficult)
walls are formed of segments that can be deleted (again, i can have i
happen using multiple game objects)'rooms' are determined if the space is enclosed: seemingly impossible. I could raycast all day long from the center of the room, if it hits a free-standing wall it thinks the room is closed when it isn't.
when a room is enclosed, you can 'paint' the floor using a 'paint
bucket tool' - again, impossible because i'm not using a tile system but free standing gameobjects. There's nothing to 'paint' because I'd have to create a flat polygon structure based on the boundaries of the room which I do not know how to obtain
TLDR: the sims did it 10 years ago - aren't there basic tutorials on the above somewhere?
Answer by jdean300 · Feb 13, 2017 at 03:45 PM
I don't know of any tutorials specific to this, but I'll help you on some of your points. You said you understand how to do the first two points from above.
For the 3rd point, you could use something called a flood fill algorithm. Start from a point in the room and then run the algorithm and you will receive all the grid-squares in that room. There are plenty of examples of these online, here is one.
For point 4 - in point one you said the user can click on the grid, so I am assuming you have a grid, yet you also say you aren't using a tile based system. You can use 'tiles' but have them be seamless to where a user cannot see tiles. Then use these tiles and the flood fill algorithm to paint the floor.
Thank you! The challenge is that I have them on a grid right, which is purely a 'snapping' mechanism so the user won't be able draw 'free' lines.
The problem with using this system alone is that I cannot figure out the maths behind doing 45degree or even more complex wall angles. I don't think it's impossible, it's just I have no idea where to start. Drawing it is one thing, but if a wall is draw at 45 degree angle on a tile, that tile has the task to track 2 rooms, which is not possible as the floor color is different. Flooding algos are also usually described in the context of 'grids' and not just random intersection of meshes.
How do you create a grid to add all these stuff . Is it a UI element or a 3D object
Your answer
Follow this Question
Related Questions
How to do room detection on non-grid based walls 2 Answers
Limiting Wall Jump to only certain Object Collisions 1 Answer
Creating a Barrier 1 Answer
A collision wall with different behavior 2 Answers