Search Unity

HexTech - Hexagon Tile Based Map Framework available on Asset Store

Discussion in 'Assets and Asset Store' started by Tasarran, Aug 29, 2011.

  1. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    I don't know those packages, except for NGUI, which works perfectly with HexTech.

    If you want to use this for overland maps, and cut to a different scene, using a different program, that should work fine.

    It should also be relatively seamless with other packages, once it has run and created the map, the map creator script is really just a repository for the map data arrays.
     
  2. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    Looks nice Allan! Interested in hearing about future updates.
     
  3. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    I don't plan on abandoning this code again; even if I get another commercial gig, I will devote at least a few hours a week to this project, for as long as I can think of things to add.

    Several things are on the immediate agenda to add to the code...

    Unrevealed terrain
    Fog of War (revealed but currently not viewable)
    Borders

    Don't want to bore anyone with the details, but I'm pretty sure I know exactly how all three of these will be handled, and they should be out relatively soon.

    Also on the list is an in-Editor map creator/editor. This is a bigger addition, but I think it is a must have...

    Now that I have developed an actual TBS game, I'm also thinking about adding some generic, starter game control functions, such as:
    - Basic framework for supporting unit lists and models on the map
    - Basic side lists and turn structure
    - Pathfinding

    Hoping I can make these things modular enough that you should be able to take a unit prefab that I provide, replace the model and a texture for the minimap icon with your own, drag a few of them into some lists on a GameManager object, and have units that you can move around the map when you push play.
    It would be very basic, just the beginnings of a game, but I think this would be common ground anyone who would want this package would need to cover next.
     
    Last edited: Apr 14, 2014
  4. terradive

    terradive

    Joined:
    Mar 26, 2014
    Posts:
    2
    How do you make this work? I can get it to display two map textures, but when I try to import the rest I have problems. I've watched your youtube video and that wasn't a lot of help.. Have I missed some instructions somewhere? How do I make my own maps? I think I'm importing them, it breaks the map out into other maps, but it displays browns hexes with oddly shape water on top...
     
    Last edited: Apr 20, 2014
  5. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    I'll post a more detailed video, but the most important thing that will cause problems with your map, is that in the Import Settings, you need to make sure the texture is set like this:
    $Untitled-1.jpg

    It needs to sample specific points on the texture, and it needs them to be the specific values, so no compression.
    Also make sure the Max Size is greater or equal to the size of the texture.
     
  6. terradive

    terradive

    Joined:
    Mar 26, 2014
    Posts:
    2
    So am I reading this correctly that you are reading pixels on a map to determine what the hex should be? Would it be easier and less memory consuming to save them in an array and then layer them?
     
  7. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    So, am I reading this correctly?

    You think it would be easier to create your map in a text editor, as a huge string of numbers, rather than making a graphical map?

    I don't agree, but it is very easy to modify it: you need to fill two arrays: one for the underlying form (or height, if its an elevation map), and one for the 'cover'.
    If you want to have roads and rivers, you'll need arrays for both of those, too.
    So, at the smallest size, you need to have at least two arrays, possibly four, with 1024 entries in each.
    To me, it was easier to deal with a graphical map than these meaningless piles of numbers.
     
  8. Sorcerak

    Sorcerak

    Joined:
    May 19, 2013
    Posts:
    7
    Well I must side with Terradive on this as a potential customer:

    It is much easier to have it as a data structure and they are far from meaningless to the application running. I was also very impressed by your addon video and about to buy it in a flash until you went on talking about an image driving the whole thing. Yes it is visual for a human but it also hinders the manipulation on run time: When, for example, a civ like game generates it's map it doesn't create a graphical map - it's just an internal data structure (ie: "huge string of numbers"). What you do with that data then creates the graphical map.

    To use your addon, since my maps are in "meaningless pile of numbers" format I'd need to generate at runtime a visual bitmap in order to get your addon to work? Am I right? I'd rather bridge with another documented data structure than to even entertain the idea of getting into this.

    Do you have internal data structures that could be bridged into storing the map data or do you constantly refer to the base image for this data? Any chance you could reconsider this approach in the near future? I can see myself patching this in your addon (and in fact would be much faster than writing code to generate the bitmap I think) but it would have to be redone on each of your update.

    Thanks and good work - hope I will be able to use this as it's exactly what I am looking for if I can interface with this in some ways.
     
  9. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    I have to disagree. Having also worked on projects like this I found the bitmap approach to be much better. I don't really see any benefit in storing the data as a string as you say. You could make an argument for using a [,] of data but that's essentially what a bitmap would be. If you can elberate on how it hinders the framework from reading off a bitmap, please do. I think I gain much by using a bitmap as I can easily debug and manually set up the world graphically.

    Edit: I'm just a random peasant. This asset isn't my work just to be clear.
     
  10. Sorcerak

    Sorcerak

    Joined:
    May 19, 2013
    Posts:
    7
    In the case of my project maps are generated procedurally so there's no visual cues or benefits to use a bitmap to store the data. I'd argue also that most projects use a visual map editor for content creation but don't store the actual map as a picture file whose pixels are scanned to determine the tile's content.. but then I'm old school so it might be a new trend as I haven't coded that much in the last decade ;)
     
  11. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    I didn't mean the data is meaningless, of course it has meaning; but I personally can't put a map together that way, it just ends up looking like a sea of numbers and commas before long. I do plan to eventually have a map editor.

    Don't get so hung up on this image input deal; all it does is load the data into arrays.
    If you have the data already, its a trivial matter to just tell the code skip the image parsing and use the data.

    I'll patch in an option to use a text file, or would CSV be preferable?
    There will either have to be four arrays, with one cell/entry for each hex, or one array, with four entries for each cell, all integers.
     
  12. Sorcerak

    Sorcerak

    Joined:
    May 19, 2013
    Posts:
    7
    XML or CSV would be the way to go I'd say. Or maybe it's unneeded if your internal arrays, as you say, can be accessed and image loading bypassed. It's also needed if you need to modify the map on the go when tile types changes.

    I'll give it a shot as I appreciate the quick response time and open-mind you show and deserve the support.
     
  13. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    Here's how it works: there are, as I said, four arrays...
    You'll either need to make your data match this format, or modify my code to interpret a different protocol.
    It would be your call which is easier.

    HeightArray[x,y] is the underlying terrain type in a country map (Ocean, Sea, Swamp, Plain, Hill, Mountain, Summit), or just the level of the terrain in an Elevation map

    TypeArray[x,y] is the overlay in both modes.

    In a country map, Height and Type are combined into one value, stored in TypeArray[x,y]

    If you want to use roads and rivers, here's how that works:

    Rivers are only tracked on three sides of a hex. An integer is built up bitwise: a small river on the NE side adds 1, a small river on the E adds 2, a small river on the SE adds 4. Medium rivers are represented by 8, 16, 32; and large rivers are 64, 128, 256.
    Add the values up, and that is the value for that hex in RiverArray[x,y].

    Roads are treated in a similar fashion, 1, 2, 4, 8, 16, 32 represent a road running from the center of the hex in each direction, starting at NE, and running clockwise.
    Add the values up, and that is the value for that hex in RoadArray[x,y].
     
    Last edited: Apr 21, 2014
  14. Sorcerak

    Sorcerak

    Joined:
    May 19, 2013
    Posts:
    7
    Sounds good. Bought, will play with it by next weekend and will provide you feedback.
     
  15. SeveredScion

    SeveredScion

    Joined:
    Oct 16, 2012
    Posts:
    45
    I'm interested, but have a few questions.

    1. So the terrain tiles are controlled by an image file. Can each terrain tile get a texture resolution that is larger than the resolution they are afforded on the master PSD?

    2. I checked out the webplayer demo in the link on the first page of this thread. I notice there is a toggle grid on/off button. Can I set HexTech so that the grid is always off--so the player never sees it?

    Thanks!
     
  16. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    1) There is a big image that is applied to a sector of 32x32 hexes. Out of the box, it is set up for 2048x2048 for this texture, but that isn't set in stone.

    2) The grid is done by a projector, you can just delete it and viola, no grid.
     
  17. SeveredScion

    SeveredScion

    Joined:
    Oct 16, 2012
    Posts:
    45
    Thanks for the info and the quick reply, Tasarran!

    To clarify, if I have a sector larger than 32x32, there will be a second map applied to tiles 33 and up?
     
  18. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    Yes, if the map is larger, additional textures will be created for each 32x32 sector.
    The way it is set up now, maps must be multiples of 32, but there is no reason why it couldn't be easily modified to make partial sectors, if you really really need a map to be, say 40x50 and no larger.
     
  19. SeveredScion

    SeveredScion

    Joined:
    Oct 16, 2012
    Posts:
    45
    Great, thanks for the info! Would the reverse also be possible--that is, modifying so that one texture would apply to, say, a 16x16 sector instead of 32x32? For greater resolution per sector.
     
  20. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    Yeah, sure.
    It would take a bit of tweaking in the code, and there's a template that draws the hexes that would need to be resized, but no problem.
     
  21. DocBuchanan

    DocBuchanan

    Joined:
    May 3, 2014
    Posts:
    2
    I guess if I had to shorten my post to a few words: It seems very logical to store data in a bitmap image, because the values read from that image are endless and can be placed in a very fast access C# data structure (Does unity's C# support Linq to entities, because that's perfect for this). If you want to, read on....


    Ok this is really long because a very bright LED lightbulb (the color of which is determined by an RGB value) went off over my head and I got really excited... and something tells me a million actual programmers figured this out years ago, or that there's something wrong with my logic.

    Either way I'm proud of myself for thinking of it all on my own, and proud of anyone who reads this post to the end without laughing at or killing me.

    I've looked into how maps are generated in a few different strategy titles, and wanted to bring up Europa Universalis 4's method. They have a static map representing the entire world, it's beautiful. See it here.

    Their approach for generation was pretty simple. They have multiple PSDs representing the map. One, in gryscle serves as a heightmap. Another, in green and blue, differentiates land from water. Others, in similar formats, set features and boundaries and such. I forget how many in total, don't feel like looking, but you get the idea.

    Here's the beauty: Each pixel stores a specific RGB value, and in Paradox's (the developers) system, each value represents something in code. For instance on the land/water map, the code for blue tells the map generator that pixel is ocean.

    I believe the maps are generated at runtime execution, reading the pixel RGB values from the various map .bmp files for the data, which are then stored in arrays. This offers several benefits.

    1. After the slow load time, the game is quick and responsive because it's pulling data from the array, not an external file or even an external data structure

    2. The values in the array can be dynamically manipulated, allowing for the map to change throughout the game. They don't take this very far in EU4, but it allows for operations like changing province boundaries and ownership, allows for the dynamic data overlays they use, and I'm sure it helps them with map label placement, which is a very cool feature. Your countries label changes and adapts as your country grows/shrinks.

    I'm sure lots of folks already know all this, I'm just excited because I learned something (I'm very VERY new), and it gave me an idea. which is...

    I'm a game modder, and believe any 4x strategy title should be developed with the modding community in mind. Often, modability is extremely limited in those games (particularly civ) because a lot of what a modder needs is tied up in the .dll. They can modify and write new scripts, they can modify XML, but they can't really modify HOW something works. The frustration is what got me interested in Unity. With my modding background in mind, this bitmap concept got me thinking... A TON of data needed for a strategy game can be stored in a single pixel, using RGB. People might not know how to code, or even how to work with XML, but they can figure out photoshop....

    RGB value is stored as a hexadecimal value, and there are over 16 million values in the 8 bit RGB color scheme, and for the last 20 years the 16, 24 and 32 bit values are more common. I math good, and that means each pixel can store... too many values for me to count. Each one of those values can mean something when read from an array. Each one of those values can mean a hundred somethings, actually, since each digit in the number can represent something.
    Furthermore, in a hexgrid, each hex has... however many pixels it has (very scientific, I know), meaning it has room for a ton of different values.

    What those values mean can be manipulated in a simple XML doc (for readability), which can also be read into an internal data structure at run time (or maybe before if a tool could be developed that compiles on demand).

    #FF0000 (red) could be determined to mean "This hex is land, with hills ranging from 10-75m high, scrub, roads, and a watch tower on it." Changing a single digit in the value could alter that, #FF0001 could be the same tile, but with no roads, or whatever. Hell, there could be ten different values that mean roads, each value representing a different type of road.

    A single value, read from a pixel and stored in an internal datastructure, could all at once be read by the graphic component to determine what to render the next frame, and read by the logic component to determine 10,000 different things.

    Not only that, but causing dynamic changes to both the graphic and logic components is as easy as coding case statements that return a different value to a position in the array. The next time it's data is read, the value will be changed and different graphics and rules will be applied.

    I guess if I had to shorten my post to a few words: It seems very logical to store data in a bitmap image, because the values read from that image are endless and can be placed in a very fast access C# data structure (Does unity's C# support Linq to entities, because that's perfect for this).
     
  22. DocBuchanan

    DocBuchanan

    Joined:
    May 3, 2014
    Posts:
    2
    lol now I'm reading the entire thread and feeling like I just got the joke.
     
  23. MrPhil

    MrPhil

    Joined:
    Sep 22, 2010
    Posts:
    40
    Long time owner, here! The update looks wonderful and perfect for a prototype I'm working on! Just want to say hi and encourage you to keep up the good work.
     
    Tasarran likes this.
  24. zenforhire

    zenforhire

    Joined:
    Nov 5, 2012
    Posts:
    65
    Questions about the import map image.

    Do you have to use a predefined template you provide?

    Can you import a PNG file produced by Hexographer?
    It would only have one color. No roads, or elevation colors.

    Cheers
     
  25. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    You'd have to tweak the code that reads in the map data a bit, but that shouldn't be too difficult...
     
  26. GD-Darren

    GD-Darren

    Joined:
    Jan 12, 2013
    Posts:
    53
    Long time buyer here too! I've been playing around with this asset lately doing a hex based game.

    I am saving the map on mysql by checking the sections and giving each possible terrain type an id, that wasn't too hard to do, however I'm having a hard time / lack knowledge of the following: is it possible to generate the maps sections procedural at runtime instead of a predefined painted map? Or maybe the ability to generate the painted map texture on runtime? If not what about in future updates? Thanks

    EDIT: I am also thinking of instead of fully procedural, creating section prefabs/maps that can connect to each other and have those sections randomly form one big map. How hard would it be to implement a way to have sections attach to each other (more than one map file for same map)? Or are sections already auto attached if placed under the same gameobject (units can move from one section to another section even if both sections are 2 different maps but they are close to each other), thanks
     
    Last edited: Jun 22, 2014
  27. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    You can do this, but the Texture.SetPixel and Texture.SetPixels functions are slow...
     
  28. Pythagoras

    Pythagoras

    Joined:
    Aug 9, 2013
    Posts:
    8
    How well does your system handle big maps? I have been trying to load a 3210x2889 texture map, which is 10x10 sectors and get memory allocation errors. Is your asset restricted to smaller maps ?
     
  29. dhemsworth

    dhemsworth

    Joined:
    Mar 27, 2014
    Posts:
    1
    A bit late of a reply, but the memory issues you're hitting are due to the sector textures. The maps can be as big as you want, but after a while all of the textures chew up memory.

    It's a pretty trivial change to the code to have the sectors load without the texture applied, and from there you can create a script attached to the sector that removes the texture when it's invisible, and puts it back in place when the sector is back on the screen again. That should get rid of your memory issues.
     
  30. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    Just released Russian Front on the Apple Store, sales are going great!
    Uses a simplified HexTech engine, with a custom painted map texture.

    Check it out through my studio's page: https://www.huntedcow.com/game/russian-front
    Or look it up on the Apple Store...

    Winter is Coming!
     
  31. kartonio

    kartonio

    Joined:
    Nov 10, 2014
    Posts:
    2
    Hey Tasarran, i just bought and downloaded Hex Tech from asset store.
    The folder is named hextech2, is that ok? Thought it was version 3.

    Anyway, i hope you'll continue to improve this, your approach is excellent imo.

    See you around, ill come back to whinne or applaud ;)
     
  32. RalphTrickey

    RalphTrickey

    Joined:
    Apr 7, 2013
    Posts:
    76
    Sounds right, I've got the same folder.
     
  33. DumbStrategist

    DumbStrategist

    Joined:
    Mar 4, 2015
    Posts:
    2
    Hey!

    Been playing with this a bit, some questions about future updates and plans, if any.

    Would indeed be nice to have the map loading code also be able to load numerical representations of map. Working with graphics is the hard part for me, and I'd sure rather use arrays. Is such an update planned, or is better to code it myself for now?

    Also, any plans to release some more helper scripts? There are a few that, I guess, everyone using HexTech uses in one way or another. Such as a script to display units in a certain tile, useful for any strategy/tactics game based on this plugin. Could make a good component of a larger toolkit, or just getting a loose collection of helper scripts would be good.

    This really is a nice asset :)
     
  34. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    Thanks! I have been so busy with for-pay work that I haven't been able to give HexTech the love that it needs.
    The image data loading is just a way to get the two arrays of numbers into the computer. That step could be eliminated entirely, and you could just provide the raw data.
    I only did it that way because dealing with a graphic map was a lot easier for my brain than dealing with a long list of numbers.

    Plans? Yes, I have lots of plans; but to paraphrase Mick Jagger; time ain't on my side... ;)

    I would really like to re-factor the whole thing into C#, I only wrote it in JS to make it easier on people new to Unity.
    But I've changed my mind about that,

    Planned features:
    Draw borders
    Draw highlighted hexes
    Select and move units
    Pathfinding

    All of which I know how to do, and have done before...

    The only problem now is finding time. I'm working now on my patron's successfully funded Kickstarter project, and it's been pretty much 14+ hour days for the past six months... (But I'm making a living as a professional game developer, so yay!)

    So, long story short; I'm glad you like it, I do plan to expand on HexTech, but I'm not sure when...
     
  35. DumbStrategist

    DumbStrategist

    Joined:
    Mar 4, 2015
    Posts:
    2
    Ah nice, these do sound pretty good! If you do ever get the time to make further updates, they will clearly be good ones. Really, if HexTech grows to have border drawing and unit movement then it would graduate from a map kit to a starter TBS kit.

    Thanks for your efforts, Tasarran!
     
  36. Tinimini

    Tinimini

    Joined:
    Mar 3, 2015
    Posts:
    8
    Looks like this stopped working with Unity 5. Any chance of getting it updated?
     
  37. ftlmars

    ftlmars

    Joined:
    Aug 30, 2014
    Posts:
    4
    what status of hextech today?
     
  38. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    I'm working on an update, in my spare time. I have a full-time programming gig right now, and we're in crunch mode to get ready for a Kickstarter drive later this month.

    Here's a screenshot of the WIP so far; I'm starting this time with a map editor. At the stage now where I am about to add the texture management.
    Plans are to make this version much more robust, with some basic tools for handling units and pathfinding.

    HexTech.jpg

    The song remains the same... It hasn't been abandoned, a new release is forthcoming; I can't say when... :(
     
  39. ftlmars

    ftlmars

    Joined:
    Aug 30, 2014
    Posts:
    4
    thanks for status update
     
  40. ftlmars

    ftlmars

    Joined:
    Aug 30, 2014
    Posts:
    4
    also
    will it work with unity 5?
     
    Last edited: Aug 31, 2015
  41. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    Absolutely. The current version works with U5, too, but there's not going to be much advantage in getting it early, the new version is pretty much all-new.
     
  42. ftlmars

    ftlmars

    Joined:
    Aug 30, 2014
    Posts:
    4
    after solving 2 errors
    MoveMeshObj.GetComponent(MeshCollider).sharedMesh = MoveMesh;
    GraphicMeshObjects.GetComponent("GMeshControl").MinimapMeshObj.GetComponent("Renderer").material = MinimapSectorMaterials;

    got it work kind of ((


    issue with GridProjector

    changed GridOnly material shader and got it work
     

    Attached Files:

    Last edited: Aug 31, 2015
  43. perludes

    perludes

    Joined:
    Oct 29, 2015
    Posts:
    1
    Hey so I have been looking for a hex terrain set for a while and was wondering if I could use yours, I don't need it for unity just wanting to make a simple map and would only need the mini map icons. So is there a way for me to just get the terrain hexes as different files?
     
  44. draphaels

    draphaels

    Joined:
    Feb 20, 2014
    Posts:
    3
    Hello! Is your version still been updated?
     
  45. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    I have a totally new version in the works, but I've been too busy on contract work to finish it.
    Look up a few posts for the WIP screenshot.

    Sorry for the lack of updates; got to pay the bills, you know...
     
  46. Skaeren

    Skaeren

    Joined:
    Feb 9, 2015
    Posts:
    14
    Just watched youtube vid. Looks good, though I think your mountains are kinda crappy. Still, it is an amazing piece of work.
     
  47. benevo

    benevo

    Joined:
    Feb 5, 2016
    Posts:
    1
    lava field (cooled) perhaps basalt for a hexagon mini game
    plateau
    salt marsh
    all fresh water formations -rec springs
    several types of volcano
    crater
    peat swamp
    rock plains
    flood
    oasis
    and many more...
     
  48. Kev00

    Kev00

    Joined:
    Dec 6, 2016
    Posts:
    229
    Any word on when your new version will be up on the Asset Store? I was about to pick up HexTech, but it looks like it was deprecated.

    btw, I really like the retro hex map symbols. Hex crawling (D&D style) is exactly what I'm trying to accomplish for my rpg game. I hope your new version is similar.
     
  49. Magnitude9

    Magnitude9

    Joined:
    Jul 11, 2017
    Posts:
    11
    Whatever happened to this?
     
  50. Tasarran

    Tasarran

    Joined:
    Jan 20, 2011
    Posts:
    327
    I've been away from publishing for a long time; the past two years have been... Interesting.

    I've finally gotten back to working on a new version, I'm including a more typical editor out of the gate this time; working in a multi-layered material for the terrain that allows borders and coloring of the map, I'm also putting in basic unit support and pathfinding (Which is what I'm working on tonight).