Box Collider 2D -failed verification- warning even when the size is reasonable

I have a script that is executed in Edit Mode, it creates various gameobjects with a Box Collider 2D component attached to each one of them, and rotates their transforms based on a logic in my game. The problem is that some of those Box Collider 2D components fire this warning after they're set:

The collider did not create any collision shapes as they all failed verification. This could be because they were deemed too small or the vertices were too close. Vertices can also become close under certain rotations or very small scaling. "

As I change the rotation from the inspector of some of those created GOs, the Box Collider 2D component works again, so the warning is due to their rotations. Also note that the scale isn't the problem as it's set to 1.

My question is, what do the "working angles" have in common? I can take into account this information in my script to only include those specific angles and therefore generating working Box Colliders. It would be better if there was a solution for this problem regardless of the transform's rotation.

avatar image

Answer by Dewald_Bodenstein 

I've just found that, as soon as the rotation is about 90 degrees around the Y or X axis, the BoxCollider2D breaks. As I understand, this would be because its like scaling the collider down on one axis and it ends up being too small.

I am using 3d objects in my scene so the rotation can be necessary. The solution would be to attach the 3d object to a child and rotate the child instead.

avatar image

Answer by qateef20031 

I added a Rigidbody2D component and it worked.

ref :

+ Recent posts