I'm facing the problem that i wish to destroy a parent object but i couldn't do so. i wish to destroy User01 while bullet hit any of these child. My code was as below. JS: function OnControllerColliderHit(col:ControllerColliderHit){ if(col.gameObject.tag =="Bullet"){ Destroy(col.transform.parent.gameObject); } } C#: public class PlayerDoe : MonoBehaviour { privateGameObject par; // Use this for initializationvoidStart(){ par = transform.parent.gameObject;} // Update is called once per framevoidUpdate(){ } voidOnCollisionHit(Collision col){ if(col.gameObject.tag =="Bullet"){Destroy(par);}} }
OnCollisionEnter - http://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html I believe Collision messages are passed onto the parent gameObject, so you just need to have the relevant OnCollisionEnter script placed on the object you want destroyed.