Hello! I’m just starting out with Unity, playing around with some 2D physics.
It seems to me that whenever I generate a mesh consisting of five irregular points, and add a “Polygon Collider 2D”, the collider only makes regular pentagons that don’t align with the mesh correctly. This results in bad collision physics.
Unity Manual says the collision points are “non-editable”, so I guess there is no way to set them correctly with code? I can move the points around in the editor but these gameobjects are generated with code so that’s not a solution.
Is there a way to make the Polygon Collider 2D understand the shape of the mesh better?
Hmm. What’s the right way to do collisions for general 2D geometry then? If it isn’t Polygon Collider 2D? I don’t know what you mean by “making my own hull”.
As I said, I need to do this in code, not the editor. Because the objects are generated during gameplay and have random shapes.
Ohh, I can edit the points after all! That makes a lot more sense.
The word “non-editable” led me astray. Because my script that tried to edit the points didn’t work, I assumed it’s because they’re “non-editable” as the manual says (actually it was just my coding error). I gave it another shot now and the points can indeed be edited just fine! Thanks a lot for clearing this up, much appreciated!
On a side note, I’m still not sure what the “non-editable” means there. I can edit the points in the editor just fine too.