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.
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)
Answer by Tasarran
Jan 31, 2012 at 09:36 PM
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.
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.
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:
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...
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.
Yes, it is a bit heavy as written, but I was trying to go for looks first. There has been no optimization...
Answer by Alverndbl
Jan 31, 2012 at 09:17 PM
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.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
6 People are following this question.
Tilemap with irregular sprites?
2D Animation does not start
Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement
2d tool required for simple sprites?
How can I draw a line at a specific angle?