Got a situation here that’s not so unique I think. Lots of similar questions, but all somewhat different. Be great to have an answer.
I need to destroy a specific child object on command of the parent.
A little background:
6 walls surround a Node. Node is the parent, has an array that says which walls are supposed to be removed during the level build process.
- I cannot use Transform.Find(), because while the walls of one node all have different names, every node’s walls use the same set of names. Unless I’ve misunderstood how .Find works.
- Tried to use a for/in to delete the walls, but all the other questions similar to this have told me it can delete the parent, and anyway it deletes children indiscriminately without some spaghetti code.
- Tried to use GetComponentInChildren with a destroy script, but targeting the right child wasn’t working and it was hitting walls that hadn’t been built by the generator yet and throwing exceptions for missing targets.
If anyone has a simple, straightforward solution, I would greatly appreciate it.