The link above will take you to the itch.io page for the game and contains any downloads for current and previous versions.
This game was created for one of the final projects for my Game Studio class. I worked alongside two of my classmates for around 4 months to create the 1.0 version of the game. I was in change of all of the programming and menu functionality as well as the UI layout and animation controllers. Much of the game was designed around me wanting to challenge my skills as a programmer, namely in ways that I am not familiar with. The thrid person camera and the object movement and placing were the two biggest challenges for me as they both relied heavily on trigonometry and other mathematical concepts to achieve the desired effect. The enemy script and inheritence was also a fun challenge as I wanted to make a cohesive system that enabled the creation of unique enemies withe the same basic movement.
The camera in this game was completly coded from the ground up by me and includes collision. The camera uses the Unity Physics.BoxCast( ) system to simulate the collisions from the camera. The third person movement of the camera was not difficult as this only required some basic trigonometry, but the trouble came when introducing the over-the-shoulder angle to the camera. The solution that I found for this issue was to have an additional box check and a raycast to determine if the camera was potruding through any walls and needed to be moved.
One of the key aspects of this game is the feature that allows the player to move furniture around the house in preperation for the night ahead. This furniture has the Unity NavMeshObstacle component and modifies the navmesh. Each piece of movable furniture has the IntFurnitureController script attached to it. The IntFurnitureController inherits from the Interactable class which dictates how the object can be interacted with, but relies on the child classes to implement what to do when interacted with.
Once the object is picked up, it is then moved using 3 raycasts. The first ray is cast directly from the camera and either hits or does not hit a valid surface that the object could possibly be placed on. The other 2 raycasts are cast one unit above and one unit to the right of the original ray while remaining parallel to the original ray. Once these other two rays are then used to find the angle that the wall is facing in relation to the world. Using this information the furniture object is then moved to the correct position in the world. Before being placed the object is checked to ensure that it is both on a surface that it is allowed to be placed on as well as not being blocked by any other objects or the player.
Each enemy (nightmare) in this game was made with a unique role and function in mind. Each of the unique enemies has their own class, but it is first important to discuss the base nightmare class.
The base nightmare class contains a behavior tree that has 4 main sequences: Target, Bed, Retreat, Spawn. The target sequence represents the enemy's actions before it has fulfilled its requirement to approach the bed and attack. The Bed sequence controls the enemy's actions when approaching the bed in order to attack. The retreat and spawn sequences are very similar to the target and bed sequences respectively, but are used when the enemy is returning to it's spawn for whatever reason. Each of these states are used in every single nightmare, but the actions performed in each are overridden by the nightmares themselves.
Each nightmare has unique movement and functions differently from one another.
Spider
Moves to four random points throughout the house before making it's way towards the bed.
Will wait at each of these points for around 10 seconds
Hitting the spider will send him back to his spawn and reset his move count before approaching the bed
Skeleton
Moves directly toward the bed right from spawn
Hitting the skeleton knocks it's head off
While the skeleton's head is off, it will run after it
After retrieving it's head, the skeleton will proceed to continue toward the bedroom
Bear
Moves directly at the player
Upon reaching the player, hits the player
Getting hit slows the player by 75% for 15 seconds
The bear can be lured away from the player by hitting a honey pot around the house
Each honey pot lasts for 15 seconds or until the bear reaches it, whichever comes first