Game Programmer
Braithwaite Code Goal
The goal of this project was to create a system by which I could generate the illusion of an infinite hallway in a modular and efficient way.
General Structure
The code for the Braithwaite Residence features 3 main scripts. The GameManager script, the HallwayManager script, and the HallwaySpawner script.
In order to make sure each iteration of the hallway could be populated with events specific to that iteration, while allowing general changes to the hallway to populate into every iteration, the game uses the GameManager script to keep track of the general game state. Its job is to monitor what has occurred in the game and feed it into HallwayManager. This includes how many hallways have been generated and the lock status of all the doors in the hallway (if a player were to unlock a door at one-point, future iterations of the hallway should also have that door unlocked.). HallwayManager reads from GameManager and, with the information it gathers from there, it initializes the variables for the moving parts in the hallway.
​
Each hallway has a HallwaySpawner actor. It takes the form of a trigger volume that is placed at the start of the hallway. The player must walk through it to progress the game. When the player walks through the HallwaySpawner, it spawns another hallway iteration at the end of the current hallway. Thus maintaining the infinite hallway illusion because the player can never see the end of the hallway before a new one is generated.


HallwayManager
HallwayManager reads off of GameManager to find out how many hallways have been instanced. This number is stored as its hallwayIndex. This way HallwayManager knows which version of itself it is, and can then set up the hallway to allow certain things to happen. Once everything has been set up through InstantiateHallway, the components of the hallway then turn themselves on or off depending on whether or not they will be used in that iteration.

HallwaySpawner

The hallway itself is a level instance. By making it a level instance, any decorative changes, props needed for cutscenes, or triggers needed for events will automatically populate to every version of the hallway. The HallwaySpawner volume is located right past the initial door that a player must pass through in order to enter the hallway. HallwaySpawner simply loads a level instance of the hallway in upon being passed through (pictured left). When HallwaySpawner generates a new hallway, it increments the hallwaysInstanced variable on GameManager so that the new hallway will be assigned a new index (by its HallwayManager). When it generates a hallway, it generates it at the location of a HallwaySpawnLocation actor. This actor is a volume that deletes the level instance for the hallway it corresponds to. In order for a HallwaySpawnLocation to know which level instance to delete, it has the HallwaySpawner of the previous hallway (which generated that instance) pass it a pointer to the spawn location's own level instance (pictured right). Then when the HallwaySpawnLocation volume is triggered, it deletes its level instance (which will always be the hallway that the player just passed through.)

