I’m working on a top down snooker kind of game. I basically made a plane in blender, cutout holes on to it, so the ball can fall through and used a subdivision surface smoothing modifier to remove all hard edges. The problem now is the ball randomly jumps while rolling over certain areas of the plane, even though it’s supposed to be a perfectly flat surface. There seems to be some problem when Unity creates the mesh collider. The moment I remove the subdiv modifier this problem goes away. Can anyone tell me why this is happening and if there’s any fix or workaround.
Try using Unity’s built in Sphere collider.
Mesh colliders are expensive on processing. My guess is that when you use the subD mesh also as the mesh collider. Unity’s physics system is hiccupping, the mesh collider is just too dense. But when you remove the subD modifier and are left with a much lower polygon mesh, its able to handle processing that in real time.
Anyways, that’s my first guess, hope it helps!
If you really need to use a mesh collider for this(which makes some sense), why not have 2 meshes. You can use the Subdivided one for the visual, and use the non-SubD one for the collider. Remember that colliders need to be under a certain number of tris if I’m not mistaken, though I don’t know if this has anything to with it or not. It very well could when you consider how much geometry is added upon using SubD.
Hey GimbalLock,
Thanks for the reply. Could you elaborate how I can achieve this with a sphere collider? It’s a plane with a hole cut out of it and the rolling sphere needs to be able to fall through. So would a complex shape like this even be possible without using a mesh collider?
Hey kburkhart84,
That’s an awesome idea. Thanks a lot! I’ll use the low poly version to create the mesh collider and the smoothed one just for visuals.
The sphere collider is for the ball :). I didn’t realize you were also using the subD mesh for the level also, till after I posted. In this instance don’t have Unity create a mesh collider at import. From there bring the sphere model into the scene, add a sphere collider component and adjust its size to match the ball. Its essentially the same Idea kburkhar84 is suggesting, substituting the mesh collider with something else.
For the level, kburkhar84 is dead on for using the low poly mesh collider. The only thing I would suggest is that you still want the rendered level mesh to be optimized as much as possible. I would apply the subD modifier in Blender and clean out all the geo that isn’t needed.
Get used to this idea. Even in classic 2d games the colliders were almost always something much lower detail than the actual visuals. Mario didn’t collide in pixels, rather in whole tiles. Other platformers would have done simple rectangles, no matter the graphics. In Unity, there are several premade colliders, with the sphere and capsule being used often, though planes get used as well. Sometimes these just aren’t enough, and you need actual meshes, but even then the mesh should be as low detail as possible, no matter how high detailed(if you need it) the visual model gets.
Thanks so much guys! Makes a lot of sense.