Procedural Cave Generation

Hi Eldh, how big a map are you talking about? The region detection code runs pretty fast on my end, though the region connection (e06 and e07) is quite heavy. I’ll look into making some optimizations.

Episode 08 is now out:

It starts to slow down on a 512*512 map. And after that it increase even more. I tried a 4048 map it took about 5 minutes of freezing to create, without the detection region it took about 5 seconds. But maybe it’s not suppose to be used with such map size.

Wow,looks interesting topic + with videos its a definitely pearl.Thanks much, will start to watch it soon.

I am not sure but I think this guy has done pretty much same thing + he has added remove geometry when user touches on screen something like we see in “Where’s my Mickey/Water?” game.Check in, Marching Squares 5, a Unity C# Tutorial

Have you added this functionality too?

1 Like

Hi idurvesh, I don’t currently plan to add that feature, but I will certainly consider it.

Here’s episode 09: collisions and textures

3 Likes

This has now been featured on the Learn site as a community tutorial series:
http://unity3d.com/learn/tutorials/modules/advanced/scripting/procedural-cave-generation-pt1

6 Likes

Amazing from the ones I´ve seen. Just a small question. Is it possible to run this, then export the created meshes to use in a different project?

There are 3rd party mesh exporters. I’d check either the wiki or the asset store.

This project has been promoted to a proper project!

1 Like

That’s fantastic Adam, thanks!

To Carve_Online: That functionality isn’t provided in the series, but as Adam suggests you can definitely find something suitable online. If you want to write something quick yourself, you’d probably want to use AssetDatabase.CreateAsset() to save the procedural meshes. CreateAsset would take in a mesh and a string for the path + filename with ‘.asset’ extension.

1 Like

Is this tutorial series compatible with Unity 4.6? I know I should make the move to 5, but I have been slow to migrate. Please let me know. This tutorial looks amazing.

Thanks michaelcapone. I have not tested it myself, but it should be fully compatible with 4.6. If there are any alterations that need to be made to the code, they should be very minor. And of course you’re always welcome to post here if you hit a stumbling block and I’ll help you get it sorted out.

I have been following along in Unity 4.6. I have not run in to any programming issues so far. However, my maps display with a bunch of unintentional vertical and horizontal lines running through it. Any idea if this is a setting I can change to remove them? Have you seen this before?

That is because you’re in perspective mode, just switch into ortho and it should look good!

1 Like

Thanks! And keep up the terrific work.

RESOLVED: PEBCAK issue. Utilized form ID10-T to resolve. Capitalize “Start” to start. Hah.

Code does nothing at 9:57 of Episode 1, using the most recent unity (5.1.1). When you click Play, nothing happens. Have checked and rechecked code. Want to move forward, but afraid of not comprehending these steps and missing something critical

Will continue forward in the meantime.

This is the most useful (pretty much only useful for me anyway) tutorial on the Unity website and i have done them all. Useful for beginners and pros alike! Unity Should get you to do all their tutorials from now on, I found the in-depth way you explain things far more useful and informative than the other tutorials hosts.

Getting a few bugs on 5.1.2 so would be great if you try following the tutorial yourself using the latest build of unity to find and rectify any small bugs that exist :slight_smile:

EDIT: Actually im thinking the bugs im getting are actually because im using some freaky patch version of unity that is both NOT 5.1.2 and also a version i didnt need. Just updated to actual 5.1.2 and everything works fine!

aha! i was having this as well!

I’m speechless, what an incredible learn project!

I was trying to extend the automata to 3d, but am having trouble visualizing the map generated, the gizmo’s not gonna cut it and even a noob like me knows instantiate is gonna blow up my puter.(after blowing up my puter). any suggestions? I need to visualize the original map so’s I can come up with some smoothing rules, I’ve nixed the outer walls so I have some small chance of seein inside if I can come up with some way to see a large enough map to make sense of the smoothing iterations. And just so’s I’m not crazy, are marching cubes even possible? hehe…16^3? (answered this last only 2^8 so feasible)

Thanks Daemonhahn and SomeSlacker, I’m glad you both enjoyed it!

SomeSlacker, I’m not entirely sure what to suggest short of coding the marching cubes in advance (using a simple test example) and just using that for your visualization? Or would the gizmos not perhaps work at least for visualizing the outer shell of the map? I’ll let you know if I think of anything helpful… Please do post pictures if you get any interesting-looking results by the way! :slight_smile:

Sebastian thank you so much for this series. I found it through a Google search on PCG in Unity(I didn’t even realize it was on unity learn as a project). Anyway it is teaching me so much and I really appreciate what you are doing. Also subscribed to your channel and looking forward to anything else you may be doing.

1 Like