After fixing a few bugs to finish of week 1, there were still issues with the procedural room generation. Most importantly, the fact rooms were able to block off other rooms. However, in order to fix this, I needed to figure out why the bug was occurring in the first place.
Understanding the Issue
Upon further analysis, I realised that every time a room was blocked by another, the room that was instantiated first (1) is always the room that blocks the room that was instantiated after it (2) – therefore the room that was instantiated after (2) is always the room that is being blocked.

This is because, between the two rooms (1 & 2), the room that was instantiated last (2) was unaware of the room that was instantiated first (1) and therefore wouldn’t know that it (2) shouldn’t instantiate a room with a door leading towards that room (1).
Bug Fixing
In order to fix this, I created a new gameobject called a ‘RespawnPoint’ (Blue) that acted very similarly to the ‘SpawnPoint’ (Red) gameobject. But it would act as a way for diagonal rooms to communicate with each other, even if they weren’t horizontally or vertically next to each other. The way that they functioned was:
- They were located on each wall of the room prefab that didn’t have a doorway
- They had a ‘closingDirection’ that dictated where the newly instantiated room shouldn’t have a doorway
- If they collided with another RespawnPoint they would both destroy eachother (And instantiate an ‘Annihilator’ gameobject that would destroy other RespawnPoints)

But the most important part of their functionality was that whenever they would collide with a SpawnPoint gameobject, the SpawnPoint gameobject would be destroyed, but the RespawnPoint object would access its openingDirection int. Combined with its own closingDirection int and the SpawnPoint’s openingDirection int; the RespawnPoint could then choose more specific rooms to instantiate that would have the correct closing direction and opening directions. However, more specific arrays would need to be added into the RoomTemplates script in order for this to work.
The script for the RespawnPoint gameobjects:



This was the addition to the ‘RoomTemplates’ script, these new arrays would allow for more specificity for RespawnPoint gameobjects to spawn rooms with specific closingDirections and openingDirections. The naming convention I created was ‘yes_no_rooms’.
The ‘yes_’ meant that the room required an opening in that direction. For example, a ‘yesTno_Room’ would require a room that had an opening upwards (To the Top of it – hence T)
The ‘no_’ meant that the room required a closing in that direction. So, a ‘yes_noBRoom’ would require a room that had a closing downwards (Towards the Bottom of the room – hence B)
Therefore, the ‘yesTnoBRooms’ array would contain any room that had an opening upwards but a closing downwards, etc.