- Home /
Unity 2D tiles and grid
I am currently working on my first Unity project, which is a 2D strategic RPG (similar to Fire Emblem).
The tile system I developed works pretty well but now I am stuck on overlaying it with a grid.
I modified the code found in this thread and it works pretty well, however now the problem is, that the lines drawn with GL.Vertex3 are drawn above everything but the GUI.
This is a problem since I wanted to have 3 sorting layers (from background to foreground): terrain, grid, units. Units can be bigger than a tile, which leads to a problem when the grid overlaps the unit :(.
Is there a way to draw the lines with GL in a specific sorting layer? Is there another good way to draw a grid?
Thanks in advance!
To get what you want you may have to go with a third-party line drawing solution like Vectrosity. Or alternately you could draw your own 'lines' but creating a mesh of line quads (essentially what Vectrosity does for some line types).
I tried creating my own mesh and rendering that with $$anonymous$$eshRenderer, however the problem is that if I want to have very narrow lines they sometimes become wider (I guess because they are not exactly pixel-aligned or something). So this does not seem like a good option :(.
I don't have time to flesh it out right now, but I converted it and made it editable.
Answer by gfoot · Apr 22, 2014 at 07:50 PM
Did you use MeshTopology.Lines? If so, the lines should always be one pixel wide. If not, try that - it's a parameter to Mesh.SetIndices.
Your answer
Follow this Question
Related Questions
How to use the same tilemaps among multiple scenes (e.g. making it a prefab)? 0 Answers
Drag Rigidbody into slots? 2 Answers
Grid Movement VS Free Movement 1 Answer
What to do with "unloaded" gameObjects? 1 Answer
2D Tile Map Question 0 Answers