Before updating to Windows 10 you may need to return your Pro license. More information here

2d hex grid map implementation

My project will be a 2d hex turn-based strategy game and I'm looking ways to implement the hex-grid map. After I made some research in unity answers/forum, I found that one way is to make a hexagonal planar (cylinder with 6 vertices) in a 3d modeler program, import it in unity and fill the grid with these tiles to make the map.

1) Do you think there is a more simple or efficient way to make the hex grid? 2) In my proposal, shall I use the various textures for each tile (grass, water, rough etc) in the modeler program or apply them in unity? 3) Is there a way to have a smooth transition from one hex tile to an other (grass to water, for example)?.

Thanks for your time and suggestions and I would appreciate as much detailed answers as possible, since I'm new to all this.

more ▼

asked Jan 21, 2012 at 03:56 AM

avatar image

31 6 4 6

I got the idea for implementing the hex-grid from http://redclovergames.com/blog/?page_id=397

I could use some ideas about the part 3 of my question, though, if anyone is interested (about the texture transition from one tile to another)

Jan 31, 2012 at 09:30 AM Astreos
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Having done a hex map framework (that is on sale at the Asset Store), I am a fan of the single-mesh-per-tile approach, for several reasons.

You place the pivot point of your actors at the base, in the center, you can instantly place them at the center of any tile. The same way, you can make them face any neighbor. And tweening between any two tiles becomes a matter of going between two points.

You don't have to worry about all the math, the way you would if you were just moving over a single mesh, using math to plot your moves.

The drawback is what you mentioned, hex transitions. To make one set of transitions to cover all the possibilities of say, dirt/grass, you have 2^6 (64) combinations. If you throw in a third possibility for terrain mixing (say, stone), it rises to 2^12 (4096).

You can either not worry about it, and make your hex all one texture for each terrain type, or do what I am trying to do, and make the features in the hex more prevalent. Is it Rough? Well, yeah, look at all the rocks scattered around there. Forests are obvious because they have trees all over them. In the swamp, the terrain is randomly dipped down into a water layer that lies under each hex. Grassy areas have grass all over them, and some small bushes.

I'm also experimenting with textures that have a background that is shared between all the hexes (dirt), and adding splotches and dots of a color (ie. dark green and brown noise for a Forest tile) in the hex that don't quite reach the hex border. This way, I can tint the color of the hex without having to worry that I'll have a blotch cut off on the edge.

more ▼

answered Jan 31, 2012 at 09:36 PM

avatar image

1.5k 48 44 58

Thank you for your help. I was thinking about the same thing. If it's forest, for example, to have a mesh textured with some trees in the middle, without painting the "rough" corners of the hex. As for the single-mesh per tile, it goes very well so far, except that in big maps (50x50) It takes awhile to instantiate all the tiles.

Feb 01, 2012 at 01:20 PM Astreos

I had to push all of the construction of the map I could into the editor, so they weren't instantiated, they were already part of the scene. But still, there is a lag at the beginning, I solve this by having all the tiles inactive at the beginning, and looping through them activating them with a coroutine, yielding to a progress countdown.

I would advise you to check out the work I have done already. You might want to look into buying my HexTech framework (not trying to sell you here, but you might), at least I think you'll be inspired by what I've done so far.

You can see this in action on this webplayer: http://www.electricrune.com/SteelSkies/UnderSteelSkies.html This is based on HexTech, but it's not quite out-of-the-box anymore. You can see a demo of the basic version on that site, too...

Feb 01, 2012 at 06:02 PM Tasarran

Very good job Tasarran. I love the terrain difference and the way you implement it. Too bad that is feels kind of "heavy" and slow even in a small map. I hope you can optimise it for speed, because it's an awesome framework.

Feb 02, 2012 at 12:50 PM Astreos

Yes, it is a bit heavy as written, but I was trying to go for looks first. There has been no optimization...

Feb 02, 2012 at 06:48 PM Tasarran
(comments are locked)
10|3000 characters needed characters left

I really do think that the most effective way is with the external 3d modeler program like blender(free one).

You can choose exactly what part of the Hex to be colored with what using textures an uv mapping that is done in blender so that you can set the uv coordinates that unity can read later. Like 1/3 sand 2/3 grass etc.

Heres an introductory tutorial on that http://www.youtube.com/watch?v=obB9T3jXlak

I haven't watched it till the end... you can easily unwrap in blender by pressing U then "Project from view" (in Edit Mode, with the faces you want to unwwrap selected) so you get exactly what you see in the view port.

more ▼

answered Jan 31, 2012 at 09:17 PM

avatar image


(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



Answers and Comments



asked: Jan 21, 2012 at 03:56 AM

Seen: 10575 times

Last Updated: Feb 02, 2012 at 06:48 PM