Trap the Shark
Concept
In "Trap the Shark," you play as a deep-sea diver in a heavy diving suit. Your mission is to trap the shark by luring it into a cage. To do this, you'll need to catch fish and use them as bait to lure the shark into a cage. But beware! The shark is dangerous and will bite if you get too close.
Contribution & Role
I worked alone on this game alone during 9 days.
Key Feature - AI State Machine
1. State Machine: Used a finite state machine for modular AI behavior.
2. State Logic: Defined behaviors for the shark to shift between states based on player actions.
3. Modularity: Separate state scripts kept code organized and easy to expand.
Background
This was one of my earliest projects, where my primary goal was to explore the 3C's (Character, Camera, and Controls) and AI. My main focus was on developing systems that support these aspects rather than on refining gameplay loops. However, I consistently kept the design pillars in mind throughout the development process.
Pillars
1. Heavy movement
One of the main goals with this project was focus on the 3C's and make the player feel like they are deep underwater and are slowed down by the surrounding water and the heavy suit.
2. Reactive shark
The goal was to implement an AI for the shark that makes it react to player actions, making it feel alive.
3. Suspense
All aspects of the game were made with suspense in mind including movement, enemy AI and visual/audio presentation.
Tech & Gameplay Design
This 9 day prototyping project focused on developing a first person 3C’s prototype. I implemented a state machine for the shark AI to manage its behavior.
AI State Machine
I wanted to use a finite state machine to drive the shark behavior. I decided to implement a state pattern that allowed me to write self contained scripts for each state that can be transitioned between according to input.
Shark state manager
</>
Context
Creates and manages instances of concrete states and passes data to them.
Shark base state
</>
Abstract state
Blueprint for concrete states and defines
methods that are used in all of them.
Concrete states
Derive from abstract state and define behavior for states.
Roaming
</>
FollowFood
</>
Eating
</>
Attacking
</>
Fleeing
</>
Once this system was set up, I could start defining how the different states would control the behavior of the shark and how to trigger state switching. Using the Follow Food state as an example, the shark's behavior is defined such that if there is food present, it finds the nearest food prefab and moves towards it. Upon reaching the food, it switches to the eating state. If no food is present, it switches to the roaming state. If the player gets too close, it switches to the attack state.
Jump and Water Resistance
To create the illusion of a heavy human underwater, I added a charge-up animation before jumping and a landing animation upon hitting the ground. Initially, the jumping felt off because the character was falling as fast as they were jumping, which didn't account for underwater friction. I fixed this by adjusting the drag, increasing it while falling to slow the descent, and decreasing it while rising to allow faster ascension. This created a more realistic underwater experience, with the player falling slower than they ascend.
Increased drag when falling
Head Bobbing
To sell the feeling of being heavy and slow, I decided to make a head bobbing script that is activated when the player moves and is grounded. The script is attached to a camera holder and simulates the head movement side to side and up and down
Reflections
This was my first time creating an AI character that actively responds to player actions, and developing a reactive system was both challenging and rewarding. Seeing the shark behave dynamically and switch between states gave me a deeper understanding of why state patterns are so valuable and common in driving AI behavior.
Compartmentalizing behaviors into separate scripts proved to be an effective approach. It kept the code organized, making it easy to understand and expand upon. Adding new states was also very manageable due to this structure.
When given the assignment, I wanted to push movement to an extreme, and what moves slower than a diver at the ocean floor? Exploring this challenge was engaging, and it deepened my understanding of the 3C’s. I now have a clearer sense of what contributes to the feeling of weight and resistance, which will inform my future work in movement design.

