Map Graph – Node-based Random Map Generation

Here’s one way to do it:
8485022--1128452--upload_2022-10-3_9-36-3.png

Before you extract areas draw an outline on the land part using the Draw Outline node. Make sure you set the “Overlap?” port to true, otherwise it will draw an outline outside the land part instead of on the inside.

Then you can extract the area like you did before and get the mask from it. :slight_smile:

Would this solve your issue?

Hi, I recently bought the Humbled Bundle bundle Map Graph came with and was wondering if there is any way to add collision to the graph this is what I have so far:
(I was following the room like tutorial)


Thanks in advance.

You can handle collisions outside of Map Graph using Unity’s own components.

For 3D gameobjects, you can use the default collider components. If you’re unsure on how to use those, here’s a short tutorial that should help you get started: https://styly.cc/tips/colider-introduction/

For tilemaps you can use a tilemap collider. There’s a short tutorial about it here: https://jon-jenkins.medium.com/adding-colliders-to-tilemaps-in-unity-96e996908145

Thanks for the help.

No problem. Let me know if there’s anything else you need help with. :slight_smile:

I’ve had some questions about whether there’s a Discord server for Map Graph, so I’ve set one up. :slight_smile:

It’s meant to become a place where Map Graph users can come and discuss Map Graph and game development in general. I’ll be around from time to time to answer questions, but if you need official support, please post your questions here on the Unity forums or sent an email to support@insanescatterbrain.com.

You can join the Map Graph Discord server here.

Hey. This is perhaps a stupid question to ask, however I am sorely in need of assistance here. I am trying to avoid the edges of a texture while drawing landmasses. To this point I have a draw circles node with a center points array of Vector2Int, the idea is to start from center points, add noise and that way avoid the edges. However I can’t assign those in the editor. Do I need to do it via script? Also I tried to use the random points node, thinking I could use it’s bounds to specify points only near the center, however I could never get to do it; as the bounds values would only define how many points are generated and if they are mostly vertical or horizontal. Is that how the node is supposed to behave or am I using it wrong(probably). Thanks in advance for whatever assistance you may provide on this!

Update: I got this to work using masks, however I still would like to know if I could do it as I initially wanted to. Also is there a way to quickly add random noise to the border of a texture?

Yes, it’s not (yet) possible to assign input parameters of array types in the inspector. I suppose it would be useful to be able to assign arrays of certain types, at least, in the inspector. I think I’ll put that on the todo list actually. For now using a script would be the way to go.

The bounds merely specify how big the area is, in which you want to generate points. If you want to make sure they’re only drawn in the center, one way you could do it, is by generating points within smaller bounds and then stamping them onto a texture with larger bounds. Something like this:
8519408--1136051--upload_2022-10-17_11-55-15.png

Sorry, I’m not really sure what you mean by generating points mostly vertical or horizontal, could you add like a screenshot or something that would help me understand what you mean?

Using a mask is the way I would recommend doing this. Is there a specific reason you’d prefer doing this another way?

You could achieve this effect by first drawing a border and then using that as a mask for drawing random noise on that border.
8519408--1136054--upload_2022-10-17_12-0-19.png

I hope I understood your questions correctly and that this is helpful in any way. If it’s not, please let me know and I’ll try to help you further the best I can. :slight_smile:

Map Graph v1.19.2 is now available.

Changes:

  • Fixed broken WebGL builds, caused by the DLL conflict fix. The new solution should now resolve possible DLL conflicts without breaking WebGL builds.

  • Floats assigned to Vector2Ints are now rounded down in certain cases, to avoid situations where they might be rounded up to a point that doesn’t exist within a texture or bounds.

  • Made some improvements to drawing lines, so that the result is more consistent.

  • Improved the way exceptions are handled so that debugger features like failed node highlighting works more reliably.

  • Map Graph’s installed and latest versions are now displayed in Map Graph’s about window.

  • Attempting to set a color outside of the texture’s bounds now throws an exception with a more concrete error message.

Check out the complete changelog here.

Hi,
The issue with horizontal manhattan connection, that I reported a while ago, has been fixed in the new version.
Thank you for your hard work! :smile:

1 Like

Great! I’m glad to hear it. :slight_smile:

Map Graph v1.19.3 is now available.

Changes:

  • Added the “Map Graph/Tile” option to the create menu to replace the “Tile” option that was removed by Unity.

This allows creating single Tile assets again, without the need for creating a tile palette.

  • Fixed bug where Map Graph wouldn’t run in multi-threaded mode in the editor with the project’s build platform set to WebGL.
    Multi-threading will still be disabled when in play mode, to simulate this limitation of WebGL builds.

  • Manual: Updated the Getting Started tutorials.

  • Manual: Updated troubleshooting page.

  • Manual: Added information about using Unity’s Rule Tile system to generate game objects, instead of tiles.

  • Manual: Added a section about creating multiple layers using game objects to the “Using prefabs instead of tilemaps” page.

  • Made various minor refactoring changes.

Check out the complete changelog here.

Map Graph v1.19.4 is now available.

Changes:

  • Added a link to the Map Graph Discord server to the about window.

  • The “New Version” window should no longer open in a too small size.

  • Ports of SaveData now have their own color and are square like for other object types.

  • Added tooltips for the options on the Map Graph Runner component.

  • Updated DeBroglie to version 2.0.0, which should result in better performance when using WFC.

  • Updated Delaunator to version 1.0.10.

  • Updated QuikGraph to version 2.5.

  • Unity no longer needs to fix the namespaces when importing Map Graph in a project using Unity 2022.1 or newer.

  • Manual: Updated node index.

  • Manual: Updated troubleshooting page.

Check out the complete changelog here.

I seem to be struggling with an important fundamental aspect of using this.
I want to use this to generate maps of 3D Prefabs. Each prefab is a fixed size. Let’s say 50x50 units as an example.
I can generate a graph that makes a texture and then converts that texture to prefabs as per the tutorial and sample scene, but the problem I have is that every pixel in the texture is treated as 1 unit in the scene. So my 50x50 sized prefabs are all stacked up every single 1unit in the scene which is clearly not what I’m going for.

How do I control this – for lack of a better word – grid size so that a pixel in the source texture is say a 50x50 rectangle in the scene that will be populated by a prefab?

IOW I want to work with prefabs other than 1x1x1 cubes.

Ahh my bad. After digging through the code for the TextureToGameobject node I realized this is simply a width and height property in the Prefab Set that I totally overlooked!

1 Like

No worries. Glad you solved it.

Let me know if there’s anything else you need help with. :slight_smile:

Map Graph v1.20 is now available.

Changes:

  • Input parameters of array types are now assignable in the inspector, if the element type was already assignable in its singular form.

  • Map Graph’s serializer now uses invariant culture to serialize objects, to fix an issue where certain types, such as floats, wouldn’t get stored correctly depending on the system’s culture settings.

  • Added “All” out port to the Areas Special Border Points node that contains all the special border points in a single set.

  • Random BSP Rooms node now checks if a room is at least 1x1 in size.

  • Removed the Mask and Placements output parameters from the Cellular Automata Texture subgraph, as they returned the results of the internal Randomly Fill Texture node, which is confusing.

  • The “New Update” window now has a button to open the package manager and the Open Asset Store button has been reduced in size.

Check out the complete changelog here.

Map Graph is back in the Unity Art Bundle! :slight_smile:

So if you missed out on it last time around. Here’s your chance to get Map Graph and a ton of other cool assets for a very attractive price.

Map Graph v1.20.1 is now available.

Changes:

  • Input parameters of type Pair can now be assigned from the inspector.

  • Input parameter array foldouts now open/close when clicking the label as well as the arrow icon.

  • Input parameters array fields are now accompanied by a element count field, for easy resizing.

  • Fixed bug where deleting an item from a input parameter of array would trigger a warning and corrupt the array.

Check out the complete changelog here.

Map Graph v1.21.1 is now available.

This release includes changes for v1.21.

Map Graph now requires the Editor Coroutines package. This is usually installed by default in new Unity versions. If it’s
not Map Graph will install it for you.

v1.21.1 changes:

  • Fixed issue where changes to input parameters wouldn’t persist if the Map Graph Runner component was part of a prefab.

v1.21 changes:

  • When running a graph asynchronously, the execution of code that needs to run on the main thread will now be spread over multiple frames by default,
    to further reduce freezing and stuttering.

The time spend on each frame can be changed on the Graph Runner component, by adjusting the “Target Time Per Frame” setting.

If you wish to restore the previous behaviour, you can uncheck the “Enable Main Thread Time Per Frame Limit” setting on the Graph Runner component.

  • There’s now a OnProgress event on the Graph Runner component, which you can hook into to track the progress of the graph processing.

  • Fixed issue that kept the “Prevent Clear?” option on the Texture To Tilemap node from working correctly.

  • Manual: Updated the create your own node section to the manual.

  • Manual: Updated the section on running a graph asynchronously to the manual.

  • Manual: Added a section on how to use the new OnProgress event.

Check out the complete changelog here.