- Home /
Highlighting tiles on a hexagonal grid
I asked this in the forums but I thought it might be better to ask here. I hope that is ok.
I am pretty new to unity, but have a bit of an OpenGL background. I have a plane with a texture on it that contains a map (for a TBS). The map is going to have a hexagonal grid (although the lines will not necessarily be drawn on). I would like to be able to highlight (by lightening) a selection of tiles to display the range of movement and darken certain tiles for fog of war. What would be the best way of doing this?
That's a pretty tall order so I'd suggest spending a few days reading the documentation, working the tutorials, watching vids, etc. There are 100's of different ways to skin a cat with Unity (or any program$$anonymous$$g problem for that matter). For example i'd have each hex as a separate mesh in a prefab and prolly an arraylist, use raycasting to deter$$anonymous$$e which hex my mouse is over and then change the texture of it's neighbor hexes within a certain range or by Tag even, then have them instantiate a particle effect maybe, or...lots of ways.
Thanks for the advice. I am far from new to program$$anonymous$$g but yeah, unity is a bit different. I did think about doing each hex as a separate mesh. I wanted to see if there was a viable solution without doing that first.
Answer by pyro · Jul 19, 2010 at 09:55 PM
One way you could do this is with ParticleEmitters. If you are very new to Unity your best bet is to check the Penelope tutorial because they use Particles to represent 2D sprites for the Orbs you collect, and you can easily modify that code into an overlay system you can use for your game grid. Also it ends up only costing 1 draw call if you do it right.
Make a 50% gray hexagon texture with appropriate alpha channels and then use that as the particle, and in the Particle Renderer set it to "Horizontal Billboard". Then use a lighter color in the shader to lighten the texture below it, a darker one to do the reverse. Different colored ones to indicate movement or attack range, etc.
I am looking to do the same thing so please let me know how this works for you!
I can render the shape I want (hexagon,square ...) but how do I fix the position of the particles ?. The penelope game has random setup for the orbs right?
Any advice please
Your answer
Follow this Question
Related Questions
2D Grid Question 0 Answers
Texture grid displayed oddly when width =/= height 1 Answer
determine neighboring cells on a hex grid. 2 Answers
creating 2d table\chess board\2d array 2 Answers