- Home /
Access the parent of a collider attached to bone
I wanted to make a hitbox around the head of an enemy character. So I placed a collider around the head bone of the enemy character.
What I would like to do, is (this script is attached to the bullet) fire off the "death" animation of the enemy character when the bullet hits the collider.
Here is my script function OnCollisionEnter(theCollision : Collision){ Debug.Log("this bullet hit: "+ theCollision.gameObject.name); if(theCollision.gameObject.name == "head"){ var myparent : GameObject = theCollision.transform.root.parent.gameObject;
Debug.Log(myparent); myparent.animation.Play("standing_death_01"); }
}
when I remove root from the path I get bone7 which is the parent bone to the head bone, but if I put root in it tells me the object is Null. How can I get to the parent object in order to play the death animation this way? Or should I give up and put the collision code on the enemy?
Your answer
![](https://koobas.hobune.stream/wayback/20220613092356im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity3d Arkanoid platform collision problem 1 Answer
collision enter 1 Answer
Problem in Collider 2 Answers
function for colliding without using rigid body's? 1 Answer
Weird Collision Detection with a Cube and OnCollisionEnter 2 Answers