- Home /
Best way to check for supports in building system?
My problem sounds simple: How do I tell my game that these bricks are no longer supported? Picture for reference on my problem:
Things I have for Data:
Each brick has a list of supports, being all the bricks it is connected to.
Easy access to any of the bricks using referential scripting
A system to mark whether or not a brick is on the edge of a shape
Markings as to whether or not a brick has been destroyed (Shown in green outline, I turn off mesh and collider.)
The ability to reconnect the bricks when and if needed (It's probably needed.)
The problems I face and the things I have tried:
Maybe I can try a sort of flood fill? That way I can check if a full circle is completed with the "Destroyed" bricks and then regroup them as another object! Catch: The possibility of congestion of "Destroyed" bricks accidentally making the wrong circle (i.e. a lot of big holes are making a cut out but the fill will accidentally go in a quick loop back to the origin, "Completing" a circle)
Well, how about I give each brick a list of what exactly is supporting it? There was a post about the Fortnite building system, it was briskly ignored, and I do need something like that. Each brick has a list of who it is supporting and who is supporting it! easy! Catch: Really not easy. How do you know what's supporting what in this dynamic mess? For example, the middle brick of a large wall could be one of the largest supporting pieces, holding about as many as the base bricks do. Really, this could get WAY too convoluted way too fast.
ONE last thing, I haven't tried but may need help with:
Every time one of these bricks gets "Destroyed" I will make a move like a race car. First, go up. Then down. left. right. forward. back. You get the idea? Its a problem if we hit a solid wall, and were good to go if we are traveling on the "Destroyed" road. Catch: Maybe it only works for cutouts? I could do a secondary check for things as shown on the picture above (Being an edge to edge cut rather than a cut-out). Second: Is this really the right approach? how breakable is this?
All in all, I feel like I'm SO CLOSE! Been working at it for a week straight about, keep getting ideas then finding problems :/. A fresh eye to the situation would be stellar!
Answer by Zaeran · Apr 06, 2018 at 01:18 PM
You can use a simple pathfinding algorithm from the ground, starting with the first brick touching the ground plane, to build up a list of connected bricks. Any brick not on the list have no bricks supporting them, as there isn't any connection to the ground.
Omg that is so simple!! lol I did not even think of this thank you so much, it makes a lot of sense now that I think of it. Leave it to me to make such an easy problem a complex mess!
Your answer
Follow this Question
Related Questions
Brute Force Search Algorithm 0 Answers
Finding the first gameobject in a List that meets a condition 2 Answers
A node in a childnode? 1 Answer
How i generate Gameobjects list? 0 Answers
GameObjects creation within boundry 3 Answers