Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Terrain Grid System - powerful and flexible voronoi, boxed and hexagonal grid

Discussion in 'Assets and Asset Store' started by Kronnect, Nov 6, 2015.

  1. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hello!

    After hundred of hours of work, we're happy to announce the availability of Terrain Grid System!



    Terrain Grid System provides advanced grid capabilities to Unity to the standard Terrain system. It can also work as a stand-alone grid independently of any terrain.

    Key features:

    - Configurable and flexible grid generation, including voronoi tessellation, boxed, rectangular and hexagonal types.
    - Two levels of regions: cells and territories.
    - Powerful selectable and highlighting system for both cells and territories.
    - Coloring and texture support.
    - Path finding support (A*). Really fast and flexible system for both boxed and hexagonal grids.
    - Different positioning options for best mesh adaptation to the terrain.
    - Extensive API (C#) for controlling the grid.

    Here're two videos showing its possibilities:












    Get it now on the Asset Store!
    https://www.assetstore.unity3d.com/en/#!/content/47215

    Enjoy!
     
    Last edited: Sep 1, 2016
    theANMATOR2b likes this.
  2. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    We added to V1.1 new APIs to make it even easier to use from your game.

    Here's a video showing how to toggle cells visibility and assign individual or canvas textures to cells.
    A canvas texture is assigned once to the grid but it's not visible. Instead parts of it will be revealed by the cells themselves so you can implement puzzle or discovery games easily. Take a look at the video below:

     
  3. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
  4. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    178
    Hi, this asset looks very promising. Is there a trial version to make sure it is what I am looking for?
     
  5. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi slimshader, there's no trial but if you have some questions you can post them here or you can write to me on contact(at) kronnect.me to discuss your requirements and see if it fits or visit our support forum on kronnect.com for more details.
     
  6. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    178
    OK, will mail you then
     
  7. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi there!

    Happy to announce V1.3 of TGS with many improvements.. we also have a new intro video with nifty examples! Check it now!
     
  8. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    V1.4 has been submitted - available now on kronnect.com - with new positioning options inside terrain (center, scale), faster mesh generation when showing territories and cells and new APIs for accessing vertices and other properties of cells.

     
    Tinjaw and BackwoodsGaming like this.
  9. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    V2.1 is now available!

    New features:
    - New demo scene #10 showing how to position the grid inside the terrain using gridCenter and gridScale properties.
    - Added mask property to define cells visibility.

    Improvements:
    - Cells will be visible if at least one vertex if visible when applying mask.
    - Canvas texture now works with territories also
    - CellGetAtPosition now can accept world space coordinates.
    - Option to prevent highlighting of invisible cells

    Fixes:
    - Fixed bug in territory frontiers line shader
     
    Tinjaw likes this.
  10. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi everyone, V2.2 update is now available.

    New features:
    - New demo scene #11 showing how to transfer cells to another territory
    - Ability to hide territories outer borders

    Improvements:
    - New API: CellSetTerritory.
    - Redraw() method now accepts a reuseTerrainData parameter to speed up updates if terrain has not changed

    Fixes:
    - Fixed lower boundary of territory in hexagonal grid
     
    Rhonibaer and Tinjaw like this.
  11. Rhonibaer

    Rhonibaer

    Joined:
    Jun 28, 2016
    Posts:
    2
    hi everyone,

    i bought the TGS, thanks for this great Asset. :)
    Cause i bought it on their Website, i can not give a Rate to it. So, only a Review.

    It's very simple to use, and great to make Cell Groups by Territorie-Assignment. Also so support of using Textures to Cells - i love it.

    The Support of the Kronnect-Team is impressive in their Forum. I always got an answer in less hours and always was helpfull.
    Requests for new Features are always checked. And when it's possible they will do it in one or another way.
    I use the Grid-System in a currently project for showing a moveable frontier, so can tell you, this asset is realy powerfull.
    https://gyazo.com/a3cb6c3069e7d753234b33f0ec3fd32a

    Thanks Kronnect-Team :)

    Best Regards,
    Rhoni
     
    Kronnect likes this.
  12. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    @Rhonibaer thank you for posting your opinion about TGS here! Looking forward to your progress!
     
  13. Rhonibaer

    Rhonibaer

    Joined:
    Jun 28, 2016
    Posts:
    2
    @Thrawn75 you are welcome. Good Software must be supported. And the correct way is to buy it, if you can - always. :)
     
  14. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi everyone!

    TGS 3.0 is now available including internal improvements and an integrated grid editor! Now you can customize cell appearance, like visibility, color or texture, inside Unity editor and export/import your configurations!

    Terrain Grid System is now included in the weekly STAFF PICK !
     
    Tinjaw likes this.
  15. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
  16. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    V3.2 is available:

    Improvements:
    - Ability to add two or more grids to same or different terrains
    - New Elevation Base property to allow set higher heights to grid over terrain
    - Updated demo scene 6b showing how to get the row/column of the cell beneath a gameobject and fade neigbhours/range of cells

    Fixes:
    - Minor fix to CellGetAtPoint method which returned null when positions passed crossed the terrain
     
    BackwoodsGaming likes this.
  17. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi everyone,

    We're happy to announce Terrain Grid System v4.0 now with path finding support!

    Here's the complete changelog:
    - A* Path Finding system. New demo scene 12.
    - Faster cells and territory line shaders
    - Added new properties to the inspector to control near clip fade amount and falloff
    - Fixed near clip fade effect with orthographic camera
     
    Tinjaw likes this.
  18. Superjayjay

    Superjayjay

    Joined:
    Mar 28, 2013
    Posts:
    60
    How do I completely erase cells (or make them invisible) so that it also applies to territories ? As it is the game field always look square or rectangular, I haven't managed to create "neutral" bits of land that really don't belong to anyone.

    Other than that, great work :)
     
  19. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi @Superjayjay!
    Thanks for using TGS.
    As you know you can use the visible property of the cell object to hide individual cells, or use a visibility mask texture. However they don't affect territories.
    We have a new update that allows you to set visibility of a territory and also they just cover the visible cells so cells visibility also affects their shape.
    Please sign up on our support forum to download this new update (we'll submit it to the Asset Store soon as well).
     
  20. Superjayjay

    Superjayjay

    Joined:
    Mar 28, 2013
    Posts:
    60
    Awesome ! Messaged the invoice no via your forums to get access to the private forum. Cheers!
     
    Kronnect likes this.
  21. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Version 4.3 is now available. Among the usual minor improvements and some fixes, the following new features are included:

    - New events: OnTerritoryHighlight/OnCellHighlight with option to cancel highlight, gives you more control over how the highlighting works. For example you could change the color of the highlight dynamically.

    - New territoryDisputedFrontiersColor property. Now you can set a different color for shared frontiers between different territories and you can specify individual territory frontiers colors using the new method TerritorySetFrontierColor:

    In this hexagonal grid, there're two territories whose frontiers are in blue and red. Note the shared frontier appears in yellow:



    Currently, TGS inspector looks like this:

     
    BackwoodsGaming likes this.
  22. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi there!

    Version 4.6 is now available on the Asset Store.

    This update adds new demo scenes, new grid-terrain fitting options, a few useful changes to make it easier to position a reduced grid around the terrain and some fixes. Recommended update!

    Complete change log:

    - New demo scene 14 "PathFinding over terrain"
    - Updated demo scene 10b with option to show neighbour cells
    - Added Max Slope parameter to hide cells hanging over terrain edges
    - Added Minimum Altitude parameter to hide cells under certain altitude
    - Added gridMeshDepthOffset and gridSurfaceDepthOffset for improved control of zfighting issues
    - Added gridCenterWorldPosition to simplify grid centering (also simplified gridCenter concept to be in the range of -0.5 to 0.5 irrespective of grid scale)
    - [Fix] Fixed some issues when coloring certain hexagonal cells
    - [Fix] Fixed/handled compatibility warnings with Unity 5.6
     
  23. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Yet another update!

    Version 4.8 is available with the following changes:

    - Added Max Movement Cost to path finding functions
    - Minor optimizations (less GC when creating cells)
    - [Fix] Fixed grid scale regression bug introduced in 4.7
    - [Fix] Fixed territory disputed frontiers color issue
     
  24. Zhuraj

    Zhuraj

    Joined:
    Mar 3, 2015
    Posts:
    2
    1.png 2.png

    Hi,
    (sorry for my bad englisch)
    i just bought your asset. I want to make a dungeon with a Hexagon overlay. But now i having trouble with multiple stages.

    How can I do this with this system?
    i've attached 2 images to show you what i mean....

    thank you.
     
  25. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi @Zhuraj
    If you want to draw the grid over the stairs or other geometry, please note that TGS currently does not support grid rendering over meshes, it’s only compatible with Unity terrain or 2D flat levels.
    TGS uses terrain heightmap to fit the grid slope and also you can assign a terrain mask so cells on certain areas are not visible (ie. cells over holes, under stairs or over non-valid player areas).
    Depending on specific requirements it could be adapted to fit some areas with some tweaks and development. Please feel free to contact us by email on contact@kronnect.me to discuss potential enhancements to the system.
    Regards.
     
  26. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi there,

    Version 5.3 is now available. Includes the following changes:

    - Editor: added toggle to enable/disable grid editing options in Scene View
    - API: Ability to assign cells to groups with CellSetGroup/CellGetGroup
    - API: FindPath method now accepts cell group mask as argument to consider only certain cell groups
    - API: Added CellGetLineOfSight() for Line of Sight computation. Example in demo scene 12.
    - API: CellGetNeighbours now accepts a range/distance. Range example in demo scene 12.
    - API: CellColorTemp, temporarily colors a cell or list of cells
    - API: Added CellGetHexagonDistance
    - Highlight Fade now accepts a range for increased effect flexibility
    - Added Hightlight Speed option
    - Max number of territories increased to 512
    - Performance improvements
     
  27. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Some quick tests on the new highlight effects:

     
  28. tetetete

    tetetete

    Joined:
    Nov 12, 2016
    Posts:
    22
    I have few question. How is voronoi diagram generated? Can I design voronoi diagram to have desirable apperance eg. I want it to look exact this way? Can I tell it which grid belong to which country and can that be changed mid game? Is that possible? Can sectors be clickable? Will it work with a* pathfinding project pro or behaviour designer?
     
    Last edited: Feb 19, 2018
  29. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Voronoi grid is generated upon a given set of random points / centers.

    Currently not, but it will be easy to modify the asset so instead of using a random set of points, use a given list of predefined points. If you're interested, just send me a pm and I'll provide an API to the asset so you can pass your own list of centers.

    Yes, in TGS each cell is part of a public List which also can contain user defined fields. So you could add a countryId field to the Cell object and use that field to determine which country belongs each cell. Alternatively TGS supports territories which is a concept very similar to countries. A territory group a list of connected cells and can be colored/textured independently.

    Yes, of course.

    TGS provides a A* Pathfinding solution but it currently does not support Voronoi grids. If you need that, you can join our support forum on kronnect.com and discuss a possible implementation (for instance, how to would you like to specify the crossing cost for a given cell).

    There's no native support for A* Pathfinding project and Behaviour Designer.

    Regards.
     
  30. tetetete

    tetetete

    Joined:
    Nov 12, 2016
    Posts:
    22
    Just checked A* Pathfinding project pro and it should work with TGS thanks to point graph. About the cost of crossing for given cell it could be basing on the distance from the center to the center.
     
  31. TriangularCube

    TriangularCube

    Joined:
    Apr 6, 2016
    Posts:
    16
    Hey there, just wanted to drop a good word with the system: it's amazing!

    Is all the documentation in the Asset Store package? I haven't found it anywhere on the Kronnect website.
     
  32. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    TriangularCube likes this.
  33. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
  34. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi,
    After some time, here's TGS 9.0 (soon on the Asset Store) with support for meshes!
    Just add the Terrain Grid System component to the root of a group of meshes (or Unity terrain) and you have a fully working grid covering the geometry.
     
    digiross likes this.
  35. whisp

    whisp

    Joined:
    Jun 21, 2014
    Posts:
    19
    There's a small bug in the TGInspector script, in the method CheckTextureImportSettings. When you assign a generated texture (with no existing asset in the asset database), a null exception will be thrown. Returning true when the path is an empty string solved it for me.
     
    Kronnect likes this.
  36. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Thanks, will be fixed in next update.
     
  37. whisp

    whisp

    Joined:
    Jun 21, 2014
    Posts:
    19
    Thanks for the fix!

    There's something else bothering me: A territory created by the Territories Texture can get disconnected, depending on cell size (only tested with Voronoi) and the shape of the territory on the texture (tight parts). When the territory of such a texture is split into two (or more) parts, the disconnected parts show as outlines, but they are not filled. They do not react on mouse-over or change color (to selection color) when hovering over the functional part of the territory.

    Also, if possible at all, it would be a nice feature to only generate cells for non-neutral territories, to speed up cells generation. (E.g. in my use-case there is a rather big terrain with a couple of small territories spread over it, and lots of neutral space in between.)
     
  38. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi,
    Thanks for the suggestions and definitely will take a look into that issue with those frontiers. If’d be nice if you can send me the texture mask and terrain in an empty scene.
    Regards
     
  39. whisp

    whisp

    Joined:
    Jun 21, 2014
    Posts:
    19
    Just created a test scene, but it doesn't work out well, since i generate and assign the territories texture procedurally in my original scene, i had to take a screenshot of the texture from an editor preview. Due to the zoom the edges are anti-aliased, which causes a lot of "different" colors at the edges.

    Anyways, here the screeny of the anti-aliased texture:



    With this texture in its (1024x1024) original size, the sand-brownish zone gets split into an upper and unresponsive lower part. Works on a flat terrain. Results may vary with amounts of Voronoi cells and seed.
     

    Attached Files:

  40. whisp

    whisp

    Joined:
    Jun 21, 2014
    Posts:
    19
    Here's a screeny of another texture:


    And a screeny of a terrain using this texture for zones:


    And a screeny of the Grid configuration:


    On the terrain one of the territories is selected (see terrain screenshot). It's the redish territory on the texture-screeny, the most left one. As you see, only the upper part of the territory gets selected. The lower part is disconnected and is not highlighted. Also when hovering over the lower part, neither the upper nor the lower part gets highlighted.

    (You might have to click the "attached files" to see the screenshots in full sizes.)
     

    Attached Files:

    Last edited: Jul 4, 2019
  41. whisp

    whisp

    Joined:
    Jun 21, 2014
    Posts:
    19
    My guess is, that the problem is related to line 1215 of TGSPrivate.cs.: Instead of the whole region only the largest connected part (the largest line strip) is made into a Polygon.

    territories [k].polygon = territoryConnectors [k].ToPolygonFromLargestLineStrip ();

    The discontinuation of the Territory itself happens within the for loop starting at line 732 of TGSTerritories.cs, where a single point of the texture is sampled at cell-center, to determine which territory the cell shall belong to.
     
  42. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Added this option to the latest beta.

    Yes, this is a restriction. Each territory should be a single connected area for highlighting purposes. The disconnected cells are still part of the territory but they won't highlight as part of the main area.
     
  43. whisp

    whisp

    Joined:
    Jun 21, 2014
    Posts:
    19
    Thanks for your answer and thanks a lot for implementing the "cells for non-neutral-only" option!

    The problem with the unconnected-territory is not just a visual one; mouse interaction (collision) is also restricted to the filled polygon only. And it's not just the highlighting that doesn't work, the disconnected territory doesn't get filled/colorized at all. Sometimes this are large parts of the territory. Since my world is random generated i can't just fix the texture or select a different cell-seed that works with the territory. This is a problem, if i want the territory to be visible.

    By means of your reaction i assume it's not simple to fix and probably little demand for it. If i interpreted you correctly ("...still part of the territory..."), the disconnected parts take part in territory based calculations. This is something i can work with.
     
  44. The_Arrival

    The_Arrival

    Joined:
    Dec 3, 2014
    Posts:
    82
    Hello @Thrawn75

    I have an Object in the Scene, which has a Component which implements TGS Events to receive GirdHover Callbacks

    i have an issue with the TGS Events. I´m subscribing in my InitMethod with
    tgs.OnCellEnter += (cellIndex) => OnHover(cellIndex);

    When the game starts, i get one single OnHover Call. Then nothing anymore. I also tried OnCellHighlight with the same outcome.

    I also tried tgs.OnCellClick += OnClick; which i´m getting no callback at all

    I have an Event System in the Scene, a Physicsraycaster on the Camera and a collider on the Object (I also implemented Unitys IPointer Events, which work)

    Any Idea what could be wrong?
     
    Last edited: Feb 11, 2020
  45. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,817
    Hi,

    Maybe some UI is blocking the raycasting? Try disabling the “Respect Other UI” checkbox.

    Regards
     
  46. The_Arrival

    The_Arrival

    Joined:
    Dec 3, 2014
    Posts:
    82
    Thanks for the fast reply. Disabling the RespectOtherUI flag does indeed help. But what confuses me is, that i have tested switching off all UIs and Canvases and it still only works, if i switch off the flag.

    Does this makes sense?

    I´m using DoozyUI, if you have ever tested your Plugin with them.

    P.S: Another thing i found is, that OnCellEnter is not fired, when the left mouse button is clicked. Other buttons work though.
    I´m trying to implement a grid-based mouse/touch-drag, so i´d need onHover to work with a pressed left mousebutton. Any suggestions?

    @Thrawn75
     
    Last edited: Feb 17, 2020
  47. The_Arrival

    The_Arrival

    Joined:
    Dec 3, 2014
    Posts:
    82
    In addition to my prior questions:

    Is there an way to get a callback/property of TGS, if the pointer leaves/enters the grid?
     
  48. The_Arrival

    The_Arrival

    Joined:
    Dec 3, 2014
    Posts:
    82
    Kind of disappointing getting no answer at all :/

    Just incase, another issue:

    When using TGS without a terrain as an overlay i get renderissues with colored cells, if i have a GameObject too close to the grid, like a ground object. Depending on the distance to the camera cell-colors do not get rendered, if the other mesh is too close. If i disable the ground-object all cells get rendered as expected though