- Home /
Question by
Vetm · Apr 22, 2014 at 08:09 PM ·
gameobjectanimatorchildchildren
Child gameObject changes name to the parent name when animated
I am making a Sidescroller and I have a gameObject named "Player". It has a child named "Sword". If "Sword" collides with a gameObject named "Zombie", "Zombie" looses heath. To detect the collision I use the following script (it is attached to "Zombie").
if (collision.collider.gameObject.name == "Sword"){
zombieHealth -= 5;
}
So far it is working. But if I add an Animator it is not working anymore. The Animator disalbles the Box Collider of "Sword" and only enables it when is playing the attack animation. I figured out, that when I enable the Animator the name of "Sword" changes to "Player". I used Debug.Log("Hit: " + collision.collider.gameObject.name);
to find out that this happens. Is there any way to slove this problem or is this a bug in Unity?
Comment