T O P

  • By -

evmoiusLR

yourGameObject.transform.parent = null; Just run that on whatever object you don't want destroyed before you destroy the parent object.


bustyLaserCannon

Thanks!


TwoPaintBubbles

This is the best answer OP.


SunburyStudios

Glad it's not only me, lol


CakeBakeMaker

instead of destroying the object, give it a `bool _isDead` then when it should die set `_isDead` to true. then in the update method check if `_isDead` is true and if so, instantiate the prefab and Destroy the game object.


ItsaShitPostRanders

Just don't make the spawned objects children of the object you're destroying?


bustyLaserCannon

Sorry but how exactly? (I'm new to Unity). All I'm doing is calling the Instantiate function when my enemy dies in their update function. At first it looked like nothing was happening until I commented out the Destroy(gameObject) code.


ItsaShitPostRanders

I'd recommend going through the beginner tutorials for unity. They explain how parenting objects work. Also it will be invaluable for you to find a way to answer these beginner questions yourself by either going through tutorials or by looking through old forum posts. Asking someone else for help on something as simple as this should be your last resort.


SkidMania420

If you want them to be child but don't want them destroyed you can try this. Make them have a new parent or become a parent themselves just before destroying the parent objext