This specific polygon collider 2d is generating a hole in its geometry and I don’t know why. The hole is that triangle in the very center there.
Here is a video demonstrating the hole. You can see a message indicating the square has entered the collider, and then a message that it left when it moves into the triangle in the center.
Here you can see I moved one point and that triangle in the center goes away.
I’m using unity 2019.4.28f1. I’m generating the polygoncollider2d paths procedurally based on meshes exported by 3ds max using this code:
The square is just a sprite with a box collider2d and rigidbody2d set to kinematic, while the polygon collider has it’s isTrigger flag set. It doesn’t matter if the object is moved into the polygon collider or the polygon collider is moved over the object. I’ve included a zip of the polygon collider along with my script to generate the debug messages. I’ll also include the actual points and paths of the collider pulled from the prefab at the end of the post. An important note is that it seems to generate different holes if the PolygonCollider2D’s GameObject’s transform is rotated differently.
If you have alternative solutions to generating a polygoncollider2d from a mesh filter or have any ideas about how or why this is happening, let me know! Thanks
EDIT: Sorry, the videos were set to private, fixed.
m_Points:
m_Paths:
- - {x: 144, y: -400.00003}
- {x: 144, y: 143.99994}
- {x: -336, y: 143.99994}
- {x: -336, y: -400.00003}
- - {x: -384, y: 175.99994}
- {x: -384, y: 47.99997}
- {x: -336, y: 47.99997}
- {x: -336, y: 175.99994}
- - {x: -336, y: 207.99994}
- {x: -336, y: 143.99994}
- {x: -144, y: 143.99994}
- {x: -144, y: 207.99994}
- - {x: -432, y: 15.999969}
- {x: -432, y: -80.00003}
- {x: -336, y: -80.00003}
- {x: -336, y: 15.999969}
- - {x: -144, y: 303.99994}
- {x: -144, y: 143.99994}
- {x: 384, y: 143.99994}
- {x: 384, y: 303.99994}
- - {x: -96, y: 399.99994}
- {x: -96, y: 303.99994}
- {x: 288, y: 303.99994}
- {x: 288, y: 399.99994}
- - {x: 144, y: 143.99994}
- {x: 144, y: -48.00003}
- {x: 384, y: -48.00003}
- {x: 384, y: 143.99994}
- - {x: 384, y: 303.99994}
- {x: 384, y: 143.99994}
- {x: 432, y: 143.99994}
- {x: 432, y: 271.99994}
- {x: 408, y: 271.99994}
- {x: 408, y: 303.99994}
- - {x: 384, y: 143.99994}
- {x: 384, y: 111.99997}
- {x: 408, y: 111.99997}
- {x: 408, y: 143.99994}
7955080–1019095–problem collider.zip (1.38 KB)