Choose Next Room
This function is the main part of the procedural generation: it's where you set your own logic to generate your dungeon.
This function is run each time the generator tries to add a room to the dungeon.
As input parameters:
Current Room
is the room from which the generator will try to add the next room.
For example, the first time this function is called, theCurrent Room
is theRoomData
asset you have returned in theChoose First Room
function.Door Data
is the door on which the next room will be connected to.
You have access to its location (expressed in room units, not in unreal units!), its orientation and itsDoorType
.
As output:
Return Value
is theRoom Data
asset you want to add as the next room. The value must be non-null and have at least one compatible door withDoor Data
.Door Index
is the index of the door (from theRoom Data
asset your return) used to connect with theCurrent Room
.
If the index is negative, it will choose a random compatible door.
If you set a value, it will take the door at the same index in yourRoom Data
asset (make sure the door is compatible!)
Here an example of a simple dungeon made by NbRoom
randomly chosen standard rooms before setting an exit room:
How can I do it?
If you struggle to write the code in this function, I would suggest you to read this page to better understand the workflow to write the code in this function.