- Home /
Detecting a collision on the child of the gameobject
Hi there,
I have a game object called Character with RigidBody2D and Box Collider2D attached to it. I've created a child of that object, called Axe, and attached a circle collider to it. alt text
Problem is that in script that handles the enemies, whenever I want to check if the collision between axe and enemy appeared nothing happens.
Here is a code I use in EnemyController to detect collision with that child:
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.CompareTag("Axe"))
{
EnemyAnim.SetBool("PlayerCollider", true);
Instantiate(blood, rb2D.transform.position, Quaternion.identity);
Destroy(gameObject);
}
}
Any tips how to dectect a collision between child of character and enemy?
Thanks in advance!
Your answer
![](https://koobas.hobune.stream/wayback/20220612135710im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
testonCollisionEnter2D testwon't testget called on collison 2 Answers
My rigidbody2d is passing through the side of a collider2d but it's working on the top 0 Answers
2d game end level with trigger and colission with trigger who to make a if condition 1 Answer
How do I make animation transitions a one-way street? 1 Answer
Unity2D game objects don't collide 1 Answer