x


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?

more ▼

asked Jul 19 '10 at 07:30 PM

Jacob 1 gravatar image

Jacob 1
38 3 3 7

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 programming 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 determine 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.

Jul 19 '10 at 09:04 PM Julian Glenn

Thanks for the advice. I am far from new to programming 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.

Jul 20 '10 at 04:56 PM Jacob 1
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jul 19 '10 at 09:55 PM

pyro gravatar image

pyro
760 4 5 23

Thanks, I'll check out that tutorial.

Jul 20 '10 at 04:50 PM Jacob 1

I am looking to do the same thing so please let me know how this works for you!

Sep 03 '10 at 07:29 PM Sammual12

How did this work out for you?

Jun 23 '11 at 03:36 PM Sammual12

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

Feb 14 '12 at 02:48 AM solana
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2193
x1034
x268
x38
x15

asked: Jul 19 '10 at 07:30 PM

Seen: 4180 times

Last Updated: Feb 14 '12 at 02:48 AM