- Home /
Question by
zee_ola05 · Feb 13, 2014 at 09:04 PM ·
2dcollisionrigidbody2d
Collision of child is detected as collision of parent with Rigidbody2D
I have an Enemy gameobject and AttackCollider gameobject. AttackCollider is parented to Enemy.
The Enemy gameobject has a Rigidbody2D component. But it has no collider. My collider is in AttackCollider.
Now when I detect collision with AttackCollider's collider, it detects colliding with Enemy. When I removed Enemy's Rigidbody2D component, it detects colliding with AttackCollider. Why is that? Can anyone explain?
void OnCollisionEnter2D(Collision2D collision)
{
// prints "Enemy" when Rigidbody2D is attached to Enemy
// prints "AttackCollider" when Rigidbody2D is removed from Enemy
Debug.Log(collision.gameObject.name);
}
screenshot 2014-02-13 14.55.33.png
(8.6 kB)
Comment