2D Collision not working! (child sprites colliders)


This is my first problem that I cannot solve without making a thread, it is just very painful dealing with this…

So the problem is that I have a parent GameObject that is my main character. That gameobject is empty, and all of his sprite parts (arms, head, feet, etc.) is made childobjects of the main character. Because they all have individual movement (in animations) and collision, and I want my parent GameObject to handle animation, player controlling and etc.

The problem is that I have tried using 2D rigidbody and a rigidbody, but they do not work; physics and collision does not work correctly. So I followed a tutorial and made “my” own, which works great, BUT, it can only have one collider. It requiers a Box Collider in the parent gameobject of all the sprites, which is very bad. I want to use all parts’ individual colliders together, not one big rectangle around my main character, the animations would not work correctly and my collision would suck.


All the small green boxes are the individual colliders of the sprites attached to “Bertil” our main character that is an empty gameobject.

This is my scripts:
Scripts DL Link

Yes you can fix it so that it collides with a certain object. For this you need to use layer for each object and assign layer to objects and call “Physics2D.IgnoreLayerCollision(int layer1, int layer2, bool ignore = true)” this method by passing the index of layer and the bool according to what you want whether object under both the layer should collide or not. Like wise you can enable and disable collision between any number of objects or collider.

IgnoreLayerCollision reference