Physics on empty body?

Rick creates an empty object called Axe, and adds a child to it called Body where he places the sprite renderer for the Axe.
He then adds an animator and animation at the root and makes the Body->Transform rotate.
This looks fine, but what happens for collisions?

Rick didn’t add a Rigidbody or Collider. I think we should add them at the root, but then when the child is rotated as Rick is doing by animation it’s not aligned?

In the screenshot I’ve select the root (Axe), and beneath it you can see the Body has been rotated (simulating a frame in the animation), yet the collider will be wrong for when it hits an attacker?

Should the root (Axe) be rotated instead?
Or should a rigid body and collider be added to the Body as well?

Hi Jamie,

Rick must add a collider to its axe. Otherwise, no collision will happen.

If the child is rotated and the collider needs to be rotated, too, it could make sense to move the collider to the child.

However, if the axe will always hit the enemies in the lane, the shape and rotation of its collider do not matter as long as the collider hits the other collider. For reasons of performance, we often try to simplify things.

Yes, please add a Rigidbody2D to the parent (Axe). If you move the collider to the child, it is not necessary to add another Rigidbody2D because the one on the parent logs all the collisions of the colliders on the children, too.

Hi Nina

Thank you for the explanation. That makes perfect sense. If I end up wanting more pixel perfect looking collision I can do as you said and move the collider to the axe body then when that rotates the collider on it will also rotate with it.

I’ll keep it simple for now though!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms