[Solved] How do i make a child game object affect the parent? [closed]


You should be able to add a collider to the child/head, BoxCollider2D for example. Then you can handle the Collision event and call a method on the parent object.

It would look something like:

// In the child/head
void OnCollisionEnter2D(Collision2D col)
{
    var goomba = transform.Parent.GetComponent<Goomba>();
    goomba.Kill();
}

This is probably the simplest way, but I think there is a way to propagate collisions to the parent, can’t remember though.

Edit:

Apparently,

If you’re using a Rigidbody with the character, you can get this out of the box. 🙂

Found that in this answer: https://gamedev.stackexchange.com/questions/151670/unity-how-to-detect-collision-occuring-on-child-object-from-a-parent-script

2

solved How do i make a child game object affect the parent? [closed]