Devlog 10: Wall Generation
This entry shall focus on wall generation.
In order to generate walls, the DungeonCreator class has been updated. Two new GameObject properties, wallVert and WallHorz, have been added to reference the prefabs for vertical and horizontal walls. These prefabs are instantiated to create the dungeon’s walls. Additionally, four lists (possibleWallHorzPos, possibleWallVertPos, possibleDoorHorzPos, and possibleDoorVertPos) are introduced to track the potential positions for horizontal and vertical walls as well as doorways.
The CreateDungeon method initializes the wall and door position lists as empty, preparing them to store data during the dungeon generation process. The CreateMesh method has been updated to calculate wall positions along the edges of each room. Horizontal walls are identified for the top and bottom edges, while vertical walls are determined for the left and right edges. These positions are added to the respective wall lists. To handle overlaps, the helper method AddWallPosToList checks if a position already exists in the wall list. If it does, the position is converted into a doorway and moved to the corresponding door list.
Once all the wall positions have been calculated, the CreateWalls method generates walls using the stored positions.
Reference List
Sunny Valley Studio. (2019). Unity 3d procedural dungeon generator. [YouTube playlist]. Available from: https://www.youtube.com/playlist?list=PLcRSafycjWFfEPbSSjGMNY-goOZTuBPMW [accessed 4 December 2024].