Download

Dungeon Generation Problems

Hello all! This has been kicking my butt for a long time and I am now completely done with trying to figure it out myself. I need your help with a problem of mine. I’ll start by explaining what is wrong and what needs to be done.

What’s wrong?
For my game, I require a system that will attach pieces (modules) together to create one huge level/dungeon. Each piece that I have is a blueprint. Here is an example of how one piece is setup just to give an idea of how each piece is made. This piece is a simple tunnel piece. I have other pieces as well.
9f398d92348d2094d67a02aee618800e50ae7143.jpeg
f56d493f928afe7ae37a4760fdd25311e2ec5332.jpeg
The red arrows on each module represent points where other modules can be attached. Modules are derived from a class I created in C++. This class has a method that will align a module with an attachment point and rotate it to match up. I know part of the code needs to be corrected too. I’m really tired and was wondering if anyone could possibly correct the following code:



/* Aligns this module with the specified module's attachment point.  */
void AModule::AlignWithAttachmentPoint(int32 UsingAttachmentPointIndex, UActorComponent* AttachmentPoint, bool bDebug)
{
	bDrawAttachmentPoints = bDebug;

	UArrowComponent* ThisAttachmentPoint = Cast<UArrowComponent>(GetAttachmentPoints()[UsingAttachmentPointIndex]);
	UArrowComponent* OtherAttachmentPoint = Cast<UArrowComponent>(AttachmentPoint);

	if (!IsValid(ThisAttachmentPoint) || !IsValid(OtherAttachmentPoint))
		return;

	SetActorLocation(OtherAttachmentPoint->GetComponentLocation());
	SetActorRotation(FRotator(0, OtherAttachmentPoint->GetComponentRotation().Yaw, 0));

	ThisAttachmentPoint->DestroyComponent();
}


This code is supposed to move and rotate the module so that both attachment points match up but it’s definitely not right. I used a temporary hack just for testing, but now I need it to match up correctly no matter what attachment point it’s connecting with. For example, this module has three attachment points:
1dce5abde69bfe4e5f8df9e4d7ac405911aad0ae.jpeg
6bc94b814eea7934c3d90d60b12f0d275d6647c0.png

Aligning this module’s first attachment point (left arrow) with another should result in the whole module rotating and moving to look like this:

000c426af510d758f7e559a964c76a38231fc159.png

Aligning this module’s second attachment point (middle arrow) with another should result in the whole module rotating and moving to look like this:

5b9adafff5667496fccc91d311d5deb58c7b249d.png

Aligning this module’s third attachment point (right arrow) with another should result in the whole module rotating and moving to look like this:

a7d77eb7f93096c0afd3fdeb1805fb51b9b68a35.png

Modules can be combined to make a level.

41d8897b7d01e5e9fc87474f686cb6d5f5f50cd4.jpeg
0af03e3554a587e9afd035fa942e107a89d0ec0b.png
In Daylight, each section of the game is procedurally generated. Though, I’m not sure about how much of it is exactly. I noticed that many rooms look the same which gave me the idea to use separate blueprint pieces and combine them to form a maze.

What needs to be done?
As I stated earlier, my game requires a feature that is able to take these and generate a huge dungeon using them. I thought I knew how to go about this (using Recursive Backtracking to generate a maze), but I guess this was not the right way. I am at the point where I’m about to explode. I feel as if I have been searching for a solution for ages. Any ideas?

Here’s an example of what it would be like, except it will be larger:
e45eef828dd0266769f953e570ca3fa440082e1b.jpeg

bump :slight_smile: