Detecting Orphaned Parts

Work continues on my ship editor. Tonight I finally decided to roll up my sleeves and sort out the logic for being able to detect when parts are no longer attached to the center of the ship. Here you can see how this works (ignore the strange issues with the selection boxes not updating correctly, it works but the gif capture messed it up):

ship-editor-in-action-3

I had originally thought about using A* to detect if each part could draw a connection back to the center but that ended up being a total mess. The way I do it now is that each part has an array of parts it’s connected to. You can call Connected() on a part and it will loop through it’s neighbors and flag that they are connected. This ends up being recursive and when it’s done I simply loop through all the parts and if they are no longer connected I change their material’s color to red.

Now I can start working on the part inventory to handle creating different ship parts as well as where parts go when you delete them.

Subscribe To My Mailing List

Want to learn how to make a game? Not sure where to start? Even if you are a seasoned game maker there is still a lot you can learn from my mailing list. I'll be covering tips and tricks for how to build, release and market games each month.

Simply sign up for my mailing list and also get access to a 50% off discount code for my eBooks and other content. I promise to not spam your inbox!

Join Now