0
\$\begingroup\$

I'm trying to construct a hexagonal prism from vertices for my turn-based strategy game. This is my first time working with meshes and I have been following this tutorial.

The problem I am having is that the sides of my shape disappear at certain angles (in this example, I only rendered the top, bottom, east, and west sides).

I have tried removing the main camera and lighting from the scene. I have tried using RecalculateBounds() but that had no effect and besides, Unity's documentation says it's not needed when assigning triangles.

The whole thing gets rendered if I position the camera perfectly, so I don't imagine I'm calculating vertices incorrectly or anything like that. Is there something I should know about Unity meshes that would cause this to happen?

enter image description here

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Make sure the normals of your model point toward the outside. \$\endgroup\$
    – Vaillancourt
    Aug 16, 2016 at 18:02
  • 1
    \$\begingroup\$ This is probably caused by using the wrong winding order for some of your faces. The order in which you specify the vertices in your index list determines which side of the triangle gets drawn, and which is disregarded as a "backface" on materials that use backface culling (including most standard materials). \$\endgroup\$
    – DMGregory
    Aug 16, 2016 at 18:06

1 Answer 1

0
\$\begingroup\$

Your drawing at least some of your sides to face the incorrect direction. We can see this in your video loop; despite looking up and into the mesh, we can clearly see the top plane. This would not happen if it was drawn with the correct facing.

By facing the wrong direction, we can see fragments of your intended mesh in the example video loop, but it will not render correctly from an outside perspective. In turn, this mostly explains why your drawn sides are disappearing when the loop moves around the back of them. One side appears to be drawn with an outward facing direction, while the other appears to have an inward facing direction.

The only time this is not evident occurs when the view is panned; It is worth pointing out that this stuff is easier to debug when you use distinctly different textures on the different sides, as the constant fuchsia can make it hard to see various inconsistencies.

It is hard to confirm the direction you are drawing your vertices at without your direct code, and the link you provide for the tutorial you followed is broken. That said, correcting your vertices to draw in counter-clockwise order when looking in to your mesh should correct your plane facing.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .