- Home /
Mesh changing in realtime
I Making a grid based city building game, and I have a BIGGGG problem:
can you make faces of a mesh turn invisible during run time? I need a way of turning the face of a mesh invisible when an object on ground level is on the same grid space as it. For some buildings like the subway station, and road, they actually go into the ground, and so the ground needs to turn invisible or get deleted so the road is visible. Thing is though, on a 500*500 grid tile size city, making each grid space a plane that can turn visible and invisible isn't efficient for mobile devices. Plz help me or Im gonna die!
I can think of several ways:
flip the normals on the vertices (would mean you'd need doubled up vertices)
regenerate the mesh and remove the triangles in those spaces
Change UVs for that tile if you use a transparent shader and pick a transparent part of the texture
You could also try this
Ahhhhhh, flipping the normals sounds quite clever. Can you do that on only 1 face on a mesh?
Better idea: ins$$anonymous$$d of recalculating the normals(would involve adding vertices, recalculating triangles, readding normals), recalculate the triangle array and skip the area.
You won't be getting around to change at least one array since you're not allowed to access those directly. If that was possible ,you could change only one tile, but my guess is, that the physics engine does need to update a couple of things upon changes. Therefore recalculating the triangle array and recalculate the normals might be the best option you have.
Answer by curiouspers · Mar 03, 2015 at 12:20 AM
Ok, so if i understand right, you want to draw entrance to subway on top of your other mesh, so your "terrain" mesh is not visible on top of your entrance mesh.
This may be done by rendering in right order, for this you need to use custom shader, that will render your "subway entrance" mesh on top of your "terrain" mesh.
If so, then I think this is what you looking for: youtube.com/watch?v=f7zDKlsyu6s
Perfect! Sorry I took so long to respond, I never got an email notification for this, or it got buried or something. Thanks sooo much, that's perfect!