i destroy a gameobject when its health reduced to zero but one of its child has a script attached to it and update of that script is still working.why is that.
even if i checked that the parent gameObject exists it gives error that the object is destroyed.but why the script in child is working
Destroying an object destroys that gameObject and all the children transforms ( so it’s components).
https://docs.unity3d.com/ScriptReference/Object.Destroy.html
Unity manual says:
If obj is a GameObject it will destroy the GameObject, all its components and all transform children of the GameObject
If you can paste the scrpit so we can check what is happening. I made a project test and when I destroy the parent, the script of the childrens are not being called.
Hello Khuram021,
Destroying a parent object does not destroy its children I believe,
I think it de-parents them and makes them become parentless.
You will have to delete all the children first.
Kind regards,
Shady