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

Map Graph – Node-based Random Map Generation

Discussion in 'Assets and Asset Store' started by InsaneScatterbrain, Aug 3, 2020.

  1. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Map Graph is the plugin for all of your level generation needs.

    Map Graph is more than a procedural level generator. It doesn't just provide you with a single level generation solution, with limited customization options. Instead Map Graph offers you the tools to easily create your own level generators, opening up a wide range of customizations and enabling you to create your own unique level generators, that perfectly suit the needs of your own unique game.



    WebGL: Demo Project






    Features

    • The visual node-based editor makes it easy to create your own level generators by dragging, dropping and connecting nodes. No coding required.

    Preview images show the result of each node, allowing you to easily see what's happening and to make quick adjustments, so you end up with the exact level generator you need.

    • With over a 100 different nodes at your disposal, you can completely customize your level generators.

    • Generate levels in the editor or at runtime.

    • Generate game objects from prefabs or tilemaps.

    • Create your own reusable subgraphs.

    • Includes a sample project consisting of 16 examples.

    • Includes extensive documentation, containing tutorials, a complete node index and API reference.


    Features for coders

    Easy to use API, to generate maps from scripts.

    Easily extendable by writing your own custom nodes.

    Source code included.




     
    Last edited: Oct 14, 2022
  2. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Here's a new map generator I made with Map Graph. It generates world maps in the style of a treasure map. Though I can feed it any set of sprites I want. :)



    The tileset I used was created by Kenney. You can check it out here! -> https://kenney.nl/assets/cartography-pack
     
    Last edited: Aug 7, 2020
    Socrates likes this.
  3. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
  4. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
  5. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    wats_Games likes this.
  6. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
  7. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Map Graph's first release is almost done! :D

    Please check out the feature showcase video!

     
  8. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Last edited: Oct 28, 2020
  9. Aiviator3

    Aiviator3

    Joined:
    Jun 26, 2014
    Posts:
    7
    Hi, I'm testing your asset for use in one of my games but I can't seem to find out how to delete nodes in a graph? In your manual the key to press is also strikken through?
    I'm working a mac Catalina and using Unity 2020.1.11f1
     

    Attached Files:

    Last edited: Oct 29, 2020
  10. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Oh, that's weird! It should say: "Press the DEL key on your keyboard." I'll fix that asap. Thanks for letting me know.

    Sorry about that! Let me know if you need more help!
     
  11. Aiviator3

    Aiviator3

    Joined:
    Jun 26, 2014
    Posts:
    7
    Thanx for your quick answer!

    I found out I needed to change my unity shortcuts for the delete key. The default forward delete key mapping doesn't work on my mac which is weird since it works fine in all my other programs.

    Now I can finally delete all those unused and un-deletable nodes ;-)
     
  12. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    That sounds a bit inconvenient, I'll see if I can bind both forward and backward delete, so both of those can be used to delete nodes. And I'll add a Delete option in the context menu, in case all else fails. ;)

    Thanks a lot for the feedback! I don't own any Apple hardware so this is extra useful information for me. :)
     
    Aiviator3 likes this.
  13. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    The new version is online.

    Both backspace and delete (I assumed those are the equivalent of forward and backward delete on a Mac ;)) will now delete selected nodes in the Map Graph editor. I also added a "Delete" option to the context menu that does the same thing.

    I hope this makes it a bit more intuitive to delete stuff, especially on a Mac. :)
     
  14. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    541
    @InsaneScatterbrain Hi, I am currently using Karcero for a RPG project i'm working on. It works well, but I had to adapt the system for use in my game and write wrappers/translators to do so. Do you think Map-Graph could be used to generate something like this? Asset looks really cool btw.
     
  15. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    I'm not familiar with how Karcero works exactly, but getting similar results is certainly possible!

    In fact, I've used an earlier version of Map Graph to do something similar for a game jam game I made with a friend of mine. (It's a 3D first person game, so it's a bit hard to see the exact result, sorry :rolleyes:)

    In Map Graph the approach would be to use the BSP (Binary Space Partitioning) nodes to generate rooms in addition to nodes to connect those rooms together.

    There isn't an example that uses the BSP nodes included in the sample project yet (I will add one in the near future), but I'll gladly help you set things up!
     
    bml and spryx like this.
  16. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    @spryx I've added a new example to the sample project that uses the BSP nodes. There's a web build of it here. You can see this example by selecting "Roguelike Level (Rooms)" in the dropdown at the top.

    Is this close to what you're looking for? :)

    The new example will be included in the next release.
     
    spryx likes this.
  17. clagrens

    clagrens

    Joined:
    May 19, 2017
    Posts:
    96
    Would you willing to make compatibility with TileWorldCreator?
    Actually I am making a 3d tile game using TileWorldCreator.
    It seem that your Map Graph support Generate 3D Map.
     
  18. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Maybe, though I'm not familiar with TileWorldCreator.

    Could you explain what you're trying to accomplish and what kind of interaction you'd like to see between Map Graph and TileWorldCreator? :)
     
  19. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Map Graph v1.1 is now available.

    Changes:

    • Added a new example to the sample project to demonstrate how to create rectangular shaped rooms using BSP nodes.
    • Added checks before running a graph to output more specific error messages whenever an input parameter is unassigned or port need to be connected, instead of the generic NullReferenceException messages.
    • Added the "Skip Checks" option to the Script Graph Runner component. When enabled the newly added port and input parameter checks are not performed.
    • The graph view no longer gets rebuild completely each time a node is added or removed. This would make the graph editor unresponsive for a short moment. This was especially noticeable for larger graphs.
    Check out the complete changelog here.
     
  20. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    I was made aware today of a bug with the sample installer. If you try to install the samples in a project based on the 2D template, it might fail with a bunch of errors and the map generators won't work correctly.

    Luckily, it seems easily fixed by restarting Unity afterwards.

    I'll look into this issue and will fix it for the coming release. In the meantime, if you run into this issue, please be aware that you might need to restart Unity for the sample project to work!

    If this workaround doesn't seem to work for you or you run into any other issues, please don't hesitate to let me know!
     
  21. dannyalgorithmic

    dannyalgorithmic

    Joined:
    Jul 22, 2018
    Posts:
    91
    this looks unbelievable
     
    InsaneScatterbrain likes this.
  22. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Thanks! :D
     
    dannyalgorithmic likes this.
  23. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Here's a friendly reminder that today is the last day of Map Graph's' release sale!

    So if you want a tool to easily create your own random map generators in Unity, this is your chance to get Map Graph at half the price! :)
     
    dannyalgorithmic likes this.
  24. dannyalgorithmic

    dannyalgorithmic

    Joined:
    Jul 22, 2018
    Posts:
    91
    I'll pick it up off sale, homie.
     
    InsaneScatterbrain likes this.
  25. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Much appreciated! :)
     
    dannyalgorithmic likes this.
  26. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    It turns out Unity has to approve any price changes, so until that happens Map Graph is still 50% off! :D
     
  27. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    The release sale has ended.

    I want to thank everyone that participated!

    I'm grateful for all the positive feedback you all gave me and I hope Map Graph will help you create lots of cool things.

    I plan to continue development on Map Graph for a long time to come so it will help you make even cooler stuff in the future! ;)
     
  28. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Map Graph v1.1.1 is now available.

    This is a minor update that addresses some issues with the sample project installer.

    Changes:
    • Improved the sample project installation script, so that it doesn't trigger errors when installed in a project using the 2D template.
    • Made changes to "New Update" window to put more emphasize on the backup notice.
    • Added a text file in the folder where the Samples.unitypackage file is located, containing installation instructions.
    Check out the complete changelog here.


    Development of v1.2 is well underway and will introduce a new node and new inspectors for the Map Graph assets, allowing for the sorting/renaming of parameters, named colors, etc.
     
    w409544041 likes this.
  29. w409544041

    w409544041

    Joined:
    Aug 3, 2017
    Posts:
    52
    Hi,any news about V1.2?
     
  30. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    It's taking a bit longer than I anticipated, but v1.2 should be coming in the next week or so. :)

    Are you running into any issues with v1.1.1 that you need help with?
     
    w409544041 likes this.
  31. w409544041

    w409544041

    Joined:
    Aug 3, 2017
    Posts:
    52
    not yet,just curious;).
     
  32. clagrens

    clagrens

    Joined:
    May 19, 2017
    Posts:
    96
    Last Month I say that is about:
    Tile world creator can generate map using 5 different tile(Auto calculate what tile to use and the rotation)
    I search all node in map graph but can‘t see the node to calculate 3d model tile rotation.

    if Mapgraph can handle 3D tile rotation it would be very helpful for 3D tile map generation


     
    Last edited: Dec 25, 2020
  33. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    You can achieve this by using Unity's rule tile system. In the sample project there are a couple of examples that use this system. These are 2D examples, but this can easily be used for 3D as well.

    For example, if you look at the sample project (info on how to install the sample project can be found here) and select the rule tile located at "Samples/Graphics/Dungeon/Tiles/Dungeon Wall", you'll see the following inspector. For 3D, instead of filling the sprite fields (1), you'd fill the Game Object fields (2) with your prefabs matching that rule.

    upload_2020-12-25_13-13-23.png


    On the Map Graph side of things, you'll want to make a Tileset instead of a Prefab Set and make some slight adjustments to your graph to use that Tileset and generate a Tilemap from it (instead of using a Prefab Set and generating GameObjects from that).

    In order to use rule tiles, you'll need the 2D Tilemap Extras package (don't let the name fool you, it's equally useful in 3D! :))

    For the sample project that package is installed automatically, but for you're own project you'll need to install it through the package manager, if you're using Unity 2020.1 or greater (how to that is described here) or through the Git repository, if you're using an older version of Unity (as described here).

    You can find more info on how to use Unity's rule tiles here.

    This should be all you need to get the result you want!

    Here's a couple of additional tips that might help though:
    • You'll probably want your tilemaps to exist on the z-plane. You can do this by selecting the their parent grid object and set its Cell Swizzle to XZY.
    • You can set a tile rule to rotate, so you don't have to create differently rotated versions of the same prefab:
      upload_2020-12-25_13-56-13.png
    I hope this helps. Please don't hesitate to let me know if something is unclear or if you have any questions! :)
     
    Last edited: Dec 25, 2020
  34. clagrens

    clagrens

    Joined:
    May 19, 2017
    Posts:
    96

    Thank you! I will try it!
    Maybe it is late but I wish you have a nice new 2021!
     
  35. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Thanks! You too! :)
     
  36. ysys-jeff

    ysys-jeff

    Joined:
    Aug 2, 2012
    Posts:
    8
    Hi~Whether to support tilemap Hexagonal ?
     
  37. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Do you mean if Map Graph can generate maps with hexagonal tiles? If so, then yes! Map Graph can generate Unity tilemaps, which support hex tiles.

    It'll work the same as the square tile examples. Only difference would be that you need to set the tilemap's grid layout to hexagonal and create a tileset containing hexagonal tiles. :)

    Does that answer your question?
     
  38. ysys-jeff

    ysys-jeff

    Joined:
    Aug 2, 2012
    Posts:
    8
    Yes, that's great.:)
     
  39. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Great! Please let me know if you have any other questions. :)
     
  40. ysys-jeff

    ysys-jeff

    Joined:
    Aug 2, 2012
    Posts:
    8
    Hi ~ please help ~
    1.
    Why does the effect deform in hexagonal tile mode?
    Is there any way to fix this problem?
    p1.png p2.png
     
    Last edited: Jan 2, 2021
  41. ysys-jeff

    ysys-jeff

    Joined:
    Aug 2, 2012
    Posts:
    8
    2.
    The graph I see in the map graph editor mode is different from the graph at runtime.
    It is difficult to determine whether it is correct.
    p3.png p4.png p5.png p6.png
     
  42. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
  43. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Unity's hexagonal grids use a offset coordinate system, meaning it uses the same basic 2D coordinates as a rectangular grid, but where the odd rows are offset. (Or columns in your case, because of the swizzle, which I'll get into with your second issue. :))

    Because of this, the shape of a tilemap that's stamped onto another tilemap, might change due to it being placed on either an even or an odd row.

    Take your tilemap's shape for example:

    Code (CSharp):
    1.  * *
    2. * * *
    3.  * *
    If you look at this in a rectangular 2D grid (which basically is the way it's stored). It would look something like this:

    Code (CSharp):
    1. * *
    2. * * *
    3. * *
    The issue here is that on a hexagonal grid, that same 2D shape also represents the following shape, when placed one row over, due to the difference in offset:

    Code (CSharp):
    1. * *
    2.  * * *
    3. * *
    So technically, what's happening here is correct, if you look at it purely based on the coordinates. However, this is obviously not what you want here, as you want to retain the shape of the original tilemap when you stamp it onto another one.

    To solve this, I'm adding an option to adjust the coordinates whenever a tilemap is stamped onto another, so that it keeps the same shape, by comparing the offsets of the rows of the original tilemap with the rows it's placed upon in the target tilemap.

    If this sounds complicated, don't worry about it too much, on your end it will just mean that you'll have to enable a checkbox somewhere, once this is implemented. :)

    I'm hoping to put up a .unitypackage patch file tomorrow that will contain this feature (though it might be in a bit of an experimental state).

    This is because Cell Swizzle is set to YXZ on the grid (to create flat top cells, I assume), instead of the default XYZ. In order to have the preview images match that, the X and Y on those should also be swizzled. I'll look into adding an option to swizzle the preview textures, for a future release.
     
  44. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    I've attached a patch to this post. It's still work in progress, but it should solve your issue. :)

    You can simply download it and then import it by selecting "Assets/Import Package/Custom Package..." and then select the .unitypackage file. (Be sure to backup your project though, in case anything goes wrong.)

    Once you've imported the patch, you should (hopefully ;)) see that that the proper shape of your original tilemap is now maintained, regardless of which row/column it's on, when you generate a new map.

    There's still some caveats I need to work out. These will be addressed in a proper release:
    • For the tilemap prefabs you use as input: make sure there's a Grid component on the object itself, with a Hexagon Grid Layout. (Looking at the screenshots you provided, it looks like you've got this covered already :)).
    • There's no option yet to switch between the previous behaviour (maintain coordinates) and this new behaviour (maintain offset/shape).
    • Tiles are shifted by one, whenever that's required to maintain the offset/shape. Because of this, it can happen that the output of a Randomly Stamp Tilemaps node has an additional column outside of the bounds provided. As a workaround you can add a border to the mask to avoid this for now.
    • If you use a margin on the Randomly Stamp Tilemaps node, it will not yet take into account any shifted tiles.
    Please let me know if this solves your issue or if you run into any other issues I haven't described here. :)
     

    Attached Files:

    Last edited: Jan 3, 2021
  45. ysys-jeff

    ysys-jeff

    Joined:
    Aug 2, 2012
    Posts:
    8
    Great! No deformation!;)
    But I also found a question, why is it not filled?:(
    p10.png p11.png p12.png p13.png p14.png
     
  46. ysys-jeff

    ysys-jeff

    Joined:
    Aug 2, 2012
    Posts:
    8
    Hi~Can you make a hexagonal example like the village in the sample?
    I feel quite difficult to make it~:confused:
     

    Attached Files:

    • p15.png
      p15.png
      File size:
      200.9 KB
      Views:
      278
  47. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    In addition to drawing the margin points, you can also draw the placement points.

    The Randomly Stamp Tilemaps node assumes rectangular tilemaps with no empty spaces (like in the village example), so even the empty parts are considered placements, that's why drawing the placement points should solve this.

    I'll adjust this in the future though, so that it will only place tiles of the tilemap set that are actually filled and place the margin around those points instead.
     
  48. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    Up until now, my main focus has been on rectangular maps, but I'll definitely be adding a hexagonal example.

    That might take a little while though, but I'll gladly help you whenever you get stuck.

    So please don't hesitate to ask for more help when you need it! :)
     
    Last edited: Jan 4, 2021
  49. InsaneScatterbrain

    InsaneScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    202
    I wanted to give a quick update on the release plans.

    I'll be releasing a version 1.1.2 first that will address some of the issues with hexagonal maps in particular.

    Version 1.2 is pretty much done (assuming the final tests don't show any big problems ;)) and will follow shortly after.
     
  50. ysys-jeff

    ysys-jeff

    Joined:
    Aug 2, 2012
    Posts:
    8
    Thanks ~ Hope to see examples soon~:)