1
\$\begingroup\$

I created a simple stair "block" in Blender, and it's rendered correctly, but when I tick "Generate Colliders" and try to use it in a Mesh Collider, there is nothing.

(Ps.: I need the real mesh as a collider, not just that generated convex one)

Maybe a good clue is that my other objects' generated colliders are smaller than the rendered meshes themselves. Maybe this one is scaled to zero?

D

enter image description here

After triangulating:

enter image description here

And via Unity's automatic triangulation: (the original, non triangulated blender model)

enter image description here

\$\endgroup\$
3
+50
\$\begingroup\$

this is just a guess that I am pulling out. but I see a missing line on the side of your stairs. No line showing up in unity seems like a hint.

mesh flaw

enter image description here

you can see triangles 012, 234, and 145 because of the textures on them. but i bet that triangle 124 doesn't exist. despite having zero area it is still a missing triangle. That's important because depending on the algorithms used a missing triangle may cause the collider generation to fail. for instance, without a closed mesh, there may be an issue determining where the inside of the mesh is to determine where the normals of the collider are.

in blender, see if there is actually a 125, 245, or 124 triangle. if not, then select the 145 triangle surface, delete it without deleting the vertices. then select vertexes 1,2,4, and 5 and create a surface across them. you may need to do the same on the opposite side of the stairs.

Before a model is sent to a graphics card and typically when a model is imported to a game engine or created in a suite like blender, everything is converted to triangles. it is how a graphics card processes all shapes, technically lines and quads are supported natively in most graphics card too, but are rarely used and not as well supported. As you can see in your unity editor, the edges of triangles are visible on the model as i highlighted above. Unity triangulated the model on its way to importing the model. With no line being visible between points 2 and 5, either unity is not drawing that edge or its triangulation algorithm failed to create it. after triangulating in Blender you do have that line. Have you tried importing that triangulated model to unity instead?

I hope that can help.

UPDATE

in future attempts we found that the vertex issue was not an issue. However we did stumble into another unity issue.

We found that when the mesh renderer was deactivated, the mesh collider generated correctly. We were able to solve the overall issue by nesting a copy of the same mesh inside itself. one level with only the renderer and the other with only the collider. This allowed the use of the concave collider

\$\endgroup\$
  • \$\begingroup\$ I don't really have triangles. (see edited original post). But i can triangulate them. How can I check whether an 124 triangle exists? \$\endgroup\$ – Tudvari Jul 17 at 15:05
  • \$\begingroup\$ @philipp in your post's comments is correct, unity collider limitations state unknown behaviour for any cooking options other than default and your cooking options are "Mixed". what are they? \$\endgroup\$ – Jody Sowald Jul 17 at 15:27
  • \$\begingroup\$ Cook for faster simulation, Enable mesh cleaning, Weld colocated vertices. \$\endgroup\$ – Tudvari Jul 17 at 15:31
  • \$\begingroup\$ i don't know why any of those would cause it to fail, but collider generation is not guaranteed for those settings. if you return the cooking options to default, does a collider generate? Please also check in your import settings that the mesh is Read/Write Enabled \$\endgroup\$ – Jody Sowald Jul 17 at 15:37
  • \$\begingroup\$ and in response to your original question, does blender display triangles when viewing your model in wireframe mode? if it does not, blender may simply not have triangles on the model until you triangulate. \$\endgroup\$ – Jody Sowald Jul 17 at 15:40
0
\$\begingroup\$

A first thought was that backface culling might cause troubles, but if you are using the default shader this issue should be visible in the rendering as well.

Did you play around with the MeshCollider Cooking Options?

Is it generating a Collider if you select the Convex option?

\$\endgroup\$
  • \$\begingroup\$ Yeah, I'm using the default shader. I didn't change cooking options: it's "Mixed": Cook for faster simulation, Enable mesh cleaning, Weld colocated vertices. Yes it is generating a collider with the convex option, \$\endgroup\$ – Tudvari Jul 12 at 16:56
  • \$\begingroup\$ Could you share are minimal project including the 3D Model on Github? \$\endgroup\$ – kala-hari Jul 15 at 7:39
  • \$\begingroup\$ I created a new project and the same thing happens. So the problem must be with the model: dropbox.com/s/rsn7k7oduu7ctjx/stairBlock.fbx?dl=0 \$\endgroup\$ – Tudvari Jul 15 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.