Collider2D not detecting collisions at all unity

Viewed 40

I am making a 2 player fighting game in unity and am using boxcollider2Ds for attack hitboxes and compositecollider2Ds for defending hitboxes. One time I noticed that the tag assignment for enemy was actually in reverse, so I changed that. but after tweaking a few more things, I noticed that the collision wasn't actually working, so I decided to print out two bools indicating if either condition was met, with the first being if the colliders were touching, and the second being if the move that was hitting you had already hit you. Both were continuously false, even after I did a move, so I soon realized that one of my colliders was in a child object but the class instance was taken from the collider in the parent object. but the collisions still didn't work and the actual collisions weren't working. Then I went to check on the box colliders and composite colliders in the actual unity UI(both being triggers) but it wouldn't detect anything, and it wouldn't even show up in the contacts tab. for reference here are what colliders are being used player1 boxcollider2d not a trigger
compositecollider2d: istrigger defending hitboxes: boxcollider2d, usedbycomposite defending hitbox 1,2,3 and 4 boxcollider2d, usedbycomposite attacking hitbox: boxcollider2d, istrigger can someone let me know what could be preventing it from detecting contacts?

1 Answers

The problem is most likely the Is Trigger bool. When it is enabled, Other objects will be able to pass through it as if it does not have a collider. Their is also different functions for both collision and trigger. the OnCollision functions are used on non Is trigger colliders while if that bool is true, the function is OnTrigger.

Related