Destroying object attached to.

hey there,

I’m not sure what it’s called, when you attach an object to another object, but anyway…

I’m developing an android game, and everytime I hold my finger on the screen, I zoom with the scope, and when I release I shoot. However my enemies consists of 2 parts: the body and the head (which is attached). Also, when I release my finger from the screen, it sends out a raycast. I then destroy what the raycast hit.

My problem is that I only destroy the head, but at the moment I want to destroy the whole body. How do I destroy an object and it’s attachment, when I am referring to to the attachment.

~Mikkelet

maybe Destroy(transform.parent);

I tried that, but it didn’t work :confused:

Use transform.parent.gameObject - this will remove the object itself rather than the transform component (they can be used interchangeably in many situations but not this one).

It worked, thanks! :slight_smile: