- Home /
Point Light not being destroyed with its parent GameObject?
I have a projectile which is being destroyed on impact with something. It has a child point light. When I play the scene I see the lights start to pile up on the ground instead of being destroyed with their parent. I don't call detachChildren, and I confirmed that onDestroy is being run. What's going on here?
var timeOut = 1.0; var detachChildren = false; var explosion : GameObject;
function OnCollisionEnter (collision : Collision) { var contact : ContactPoint = collision.contacts[0]; var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal); var instantiatedExplosion : GameObject = Instantiate (explosion, contact.point, rotation); Destroy(gameObject); }
function Awake () { Invoke("DestroyNow", timeOut); }
function DestroyNow () { if (detachChildren) { transform.DetachChildren(); } Destroy(gameObject); }
Your answer
![](https://koobas.hobune.stream/wayback/20220613105140im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
game object is not being destroyed 1 Answer
Keeping a destroyed game object afterwards 0 Answers
Ignore awake function call to destroy game object if character enters trigger 1 Answer
Destroying an Instantiated GameObject 4 Answers