Hello,
I am making a space-exploration game, and I cannot figure out how to generate unique meshes and colliders from code in a sphere/asteroid-like shape. I would prefer to use as few separate scripts as possible.
That’s a big subject Try instantiating a sphere then applying a random variation to all the verts. There are a lot of discussions on procedural generation, usually using noise functions.
There is also a Unity example project for procedural generation
Even with a tiny variation, there are small cracks around the edges of what appears to be six planes. Is there a way to remove these? Also, is there a way to recalculate the collider based on the mesh?
I may be wrong, but when two triangles share a vertex, it’s not just one vertex. It’s two, but they both have the same coordinates. So if you move one without moving the other the same amount, you end up with gaps in the geometry. Just looping through all of the vertexes and randomly assigning new values isn’t sufficient. You have to assign the random values to all of the vertices that share a common coordinate.