2D Procedural dungeon

Can anyone point me in the right direction to make a randomly generating dungeon, that is 2D.

My current game:
http://dl.dropbox.com/u/43867531/Dungeoneer/Build/v3/WebPlayer/WebPlayer.html

Look at this thread. It’s for 2.5D, but concept is exactly the same :

http://forum.unity3d.com/threads/114898-Generating-Levels

Thanks, I will check it out.

The inventory bar still doesn’t work for me. :frowning:

:frowning: I’m not sure why D: I will be sure to add the 12345678910 keys.

It doesn’t help too much, as our games are pretty different, and your code isn’t commented so I’m not sure what exactly it’s doing.

I was thinking that I could try and generate a big cube of X and then go through and delete a bunch of them but then I would end up with lots of irregularity… Or I could go through and do some modular pieces that will randomly spawn. But that wouldn’t be horribly exciting.

Make an array of game objects that make up parts of the dungeon and have the start of each one the same as the end, so they integrate with each other flawlessly. then instantiate NameOffArray[random.range(0,NameOfArray.length)]

Yes, I understand that part. But that would just keep generating a string of blocks. I’m not sure how to make it a big cube of blocks and then have pathways and such to walk around inside of it.

Yep, I’m pretty clueless on how to do this.

All I ended up doing was generating a string of blocks and then crashing unity.

I’m in the process of making a ‘dungeon’ of sorts, procedurally. This time I’m doing it dirty and quick and using prefab rooms. Each room has multiple door-nodes (each node has a list of possible rooms it can spawn out). If the nodes aren’t used, it appears as a flat wall.

Right now the only trouble is making sure 2 rooms don’t intersect in someway.

well… I sat there and though for like 3 hours and just made this:

http://dl.dropbox.com/u/43867531/Dungeoneer/Build/v4/WebPlayer/WebPlayer.html

Keep walking to the right. it procedurally generates as you go. Also, there is a chance for little irregularities to occur. How would I expand it so that whole hills happen?

Heres the code, please tell me what I can improve!

var Block 	   : GameObject;

var lastBlock : GameObject;

var Player : GameObject;

var generatedInt : int;

function Update ()

{



		Generate();



}



function Generate ()

{

	var nextPos : Vector3 = new Vector3(lastBlock.transform.position.x + 0.5, lastBlock.transform.position.y, 5);

	var dist = Vector3.Distance(Player.transform.position, lastBlock.transform.position);

	

	if(dist < 5)

	{

	

		generatedInt = Random.Range(0,70);

		

		if(generatedInt > 10)

		{

			var newBlock : GameObject = Instantiate(Block, nextPos, lastBlock.transform.rotation);

			lastBlock = newBlock;

		}

		

		if(generatedInt <= 10)

		{

			var nextPosB : Vector3 = new Vector3(nextPos.x, nextPos.y + 0.5, 5);

			var newBlockB : GameObject = Instantiate(Block, nextPosB, lastBlock.transform.rotation);

			print("Stuff Here");			

		}

		

	}



}

For some reason, I can’t jump. It’s the up arrow key right? I tried space too.

Works awesome!Controls are WAD W-jump

Procedural generation is a hard art that requires strong math programming skills, maybe you should consider building the levels the traditional way for now?

Probably.

Jump is the W key.

I will try and expand on this but It is already kind of advanced the way it is, I might just hand make the levels for now and then experiment with procedural dungeons. Does anyone know if its possible to make a tiled map editor for unity? Currently all those tiles are just planes scaled at 0.5. It’s VERY tedius to go in and edit the position of each of them one by one.

Thanks,
Dusk

I would dissect this as a starting point: http://www.stevegargolinski.com/minidungeon-a-free-random-dungeon-jump-start-for-unity/ it’s designed for a top-down sort of game (although thats arguably given the simplicity of the placeholder art) but the general idea would be the same for a side-scroller.

You can also read thelastbanana’s article on the level generation in his game, Drillboid, here: http://mildlydisconcerting.com/drillboid/2011/01/20/procedural-generation/

Wow, thanks!