About
A blind monster prowls the abandoned city, standing between you and your freedom. Can you sneak silently enough to escape?
Project info
Team size: 17
Duration: 10 weeks
Engine: BGGE(Custom engine)
ROLE
Gameplay & AI programmer
CONTRIBUTIONS
Monster AI
Rat AI
Breakables
MONSTER AI
The monster is the main antagonist and hunts you throughout the whole game. It is blind and can not see you, but has very good hearing. So you have to be silent otherwise the monster will find you and kill you.
So how does the monster work?
The monster is built on a state machine with 13 states.

WANDER
Makes the monster wander around randomly until it hears something.
CHASE
Makes the monster run towards the sound and then switch to the attack state.
STUNNED
The monster enters this state when shot and gets staggerd andd disorientated for a moment.
WAITING
Does nothing, only used at the end of the game if you get killed so the monster stops.
LISTENING
Was a state where the monster would stop, listen and search the nearby area but got taken out of the game.
ATTACK
Makes the monster slam its ball in the direction of the sound hurting anything hit by it.
SMALL ATTACK
The small attack makes the monster do a quick slash attack in the direction of the sound.
SCREAM
The scream is mostly used to signal that the monster is angry and will enter the chase state.
LOCKED DOOR
This state is triggered when the monster has collided with a locked door and will make the monster scream at the door and walk the other direction.
END CHASE
This states gets forced at the end chase sequence of the game and makes the monster always run to your position, killing you if gets to close.
ULTRA RAGE
Ultra rage is a state that gets triggered when it has been in the chase state for too long. This makes the monster run twice as fast and kill you quicker. This was implemented as a safeguard for people running around everywhere and not playing stealthily.
INTRO
This state is forced at the beginning of the game and makes the monster do a very specific set of actions. This is to introduce the monster and its mechanics without the player being in danger.
DEATH
And finally this state is triggered at the end of the chase sequence at the end of the game making the monster jump to its death.
NAVIGATION
The monster navigates using a navmeh exported from Unreal Engine which we use as our editor.
In the image below you can see the navmesh with blue and orange lines and the monsters current path with the light blue lines.

REACTING TO AUDIO
For the monster to be able to hear sound we made an Audio event system that sends out an audio event whenever a specific audio is played.
This audio event then gets sent to the monster if it is inside the sounds range.


As seen above the audio event contains some useful information about the sound. Which it uses to determine what type of object made the sound and how loud it is. The louder the sound the more angry the monster gets.
AGRESSION
The monster has a float called aggression which it uses to determine how angry it is. The aggression increases when hearing sounds and decreases slowly over time.
When the aggression reaches 100 it will rage and attack wildly until its aggression reaches 0 and it returns to normal again.
The monster also acts a little differently based on how much aggression it has. For example it has a different idle animation after 60+ agression.
CHALLENGES
Probably the thing I spent the most time working on was tweaking and balancing the monster so that it is scary but also fun to play against.
For example you want it to feel like the monster can easily kill but make it so that it almost kills the player. Because dying is not fun and almost dying is scary.
There was also a lot of balancing trying to account for all the different play styles people have. Trying to make it more aggressive towards players who aren’t scared and less aggressive to people who are very scared.
RAT AI

The rat is a small enemy designed to lure the monster to it and make the player have to avoid it. It can not attack the player and only tries to stay away from you protecting its food.
So how does it work?
The rat is also build with a state machine, but has 8 states.

IDLE
Makes the rat stand still and sometimes eat.
AGITATED
Makes the rat look at the player trying to get the players attention with small sound but not calling the monster.
SCREAM
Makes the rat scream and call the monster to its location.
BACKAWAY
Makes the rat back away from the player when he is to close to the rat.
RETURN
If the rat is far away from its original position it enters this state making it walk back to it.
MONSTER NEARBY
It enters this state when the monster is nearby makes it try to avoid the monster.
DEAD
The rat is dead an lies on the floor. The rat can be killed by both the player and the monster.
DANCE
A small easter egg in the game where the monster and rat is dancing together.
CHALLENGES
The most challenging part of the rat was trying to make it feel alive. Making it react to different things grounding it in the environment.
BREAKABLES
I implemented a system for breaking things in the game.
So how does it work?
The system works by first having a normal mesh and a destroyed mesh. It is important that the destroyed mesh has its different parts as elements of one mesh and is named the mesh name + _Destroyed.
Then not broken mesh gets placed in the world with the tag “Breakable” which adds the Destructible component to it.
The first thing the Destructible component does is find the destroyed mesh.

Then I loop through the elements creating a new entity for every piece.
Because the breakables in our game are so small I use the bounding box of each piece to create a box collider which is not perfect but saves performance by not having to generate a mesh collider for every piece.
The code for generating the entities.

Then I detect when it hits something hard by getting the impulses from Physx and multiplying it with the inversemass off the object. Then if that force is greater than some value and the velocity of the object is greater than some value it breaks.

Finally breaking the object is done by deleting the original non destroyed object and activating all the pieces. I also send a Audio event here so the monster hears this extra well.

CHALLENGES
The hardest part of creating this system was working out a nice way of doing this where the level designers and artists don’t have to do a lot. I think I came up with a pretty simple solution, because they only need o create a broken model and give the object a tag in Unreal for it to work.





