Coding For Wall Removal
![](https://i0.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/panic_button_press.gif?resize=157%2C116&ssl=1)
D038 #PanicRoom
![](https://i0.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/2020-06-15_Unity_removing_top_bottom_walls.png?resize=492%2C303&ssl=1)
I do not have a lot to show for what I’ve been working on, as it is mostly code-based, but the work has definitely been going in. I spent several hours figuring out how to tackle removing the pieces of exterior walls at the ends of the hallways and just coming up with a way to approach how I would do it.
![](https://i0.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/2020-06-15_notepad_script_ConnectHalls_notes.png?resize=800%2C342&ssl=1)
![](https://i0.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/2020-06-15_notepad_script_ConnectHalls_horizontal.png?fit=800%2C70&ssl=1)
![](https://i2.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/2020-06-15_notepad_script_ConnectHalls_vertical.png?fit=800%2C76&ssl=1)
![](https://i0.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/2020-06-15_Unity_removing_side_walls.png?resize=471%2C289&ssl=1)
At first, it seemed like a monumental challenge, but I approached it logically and laid out my intent before ever considering how it would be implemented. I think tackling it in this manner actually made it easier to solve: I outlined what I wanted to have happen, then went back and worked on one small bit at a time, with lots of testing with each little baby step. Before I knew it, I had something to show that was working the way I wanted it to!
![](https://i0.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/2020-06-15_notepad_script_HouseBuilder_ConnectHalls_array_declaration.png?resize=800%2C95&ssl=1)
![](https://i0.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/2020-06-15_notepad_script_HouseBuilder_ConnectHalls_array_initialization.png?resize=570%2C145&ssl=1)
The hardest part was figuring out how to be able to Destroy a GameObject without getting a vital asset warning. This was because my first attempt to simply remove the instantiated wall tiles was merely me trying to directly delete a prefab, which doesn’t fly in Unity. In order to do this properly I had to set up a reference to a prefab clone and remove that instead. It sounds complicated, and honestly, it kind of was for a few minutes, but some careful research led me down the correct path where I discovered how I should actually be setting this up. In my case it was as easy as setting up a new 2-dimensional array, corresponding to my grid layout system, and instantiating my wall pieces into that array for later manipulation. It worked beautifully and gave me the results I wanted!
![](https://i2.wp.com/gamedev.sinwyrm.com/wp-content/uploads/2020/06/2020-06-15_notepad_script_HouseBuilder_proper_object_instantiation.png?fit=800%2C288&ssl=1)
R2D08 #100DaysOfCode
R2D03 #100DaysOfGameDev