top of page

Operation Phantom Game Development

In this project, I set out to learn how to develop a stealth-based game inspired by the mechanics and design of the Hitman series. My primary goal was to understand and implement core stealth gameplay features, including player detection systems, AI behaviors, and mission design that challenges players to navigate environments undetected. This project allowed me to explore the intricacies of stealth mechanics and how to create engaging scenarios that encourage strategic thinking and planning.

Role

Lead Developer

Game Engine

Unity

team size 

1 person

Genre

Action Role-Play (Souls Like)

Technologies used

image.png

Unity

image.png

C#

image.png

GIT

image.png

Photoshop

image.png

Audacity

image.png

Trello

Coding Process

1

Concept & Planning

rough coding

2

Development

3

In developing Operation Phantom, I followed a five-step design process, which I will elaborate on throughout this portfolio piece. Each phase was crucial in shaping the game's mechanics, systems, and overall player experience.

Testing & Iteration

4

passover and feedback

5

Player Systems

This breakdown showcases the core player systems I developed for a first-person and third-person hybrid shooter. Each system was designed with a focus on modular architecture, clean separation of responsibilities, and responsive gameplay mechanics that deliver an immersive experience.

Core Player System Implemented

System

physics-based FPS

third-person camera

movement controller

InputManager

Details

A physics-based FPS combat system with realistic shooting, ammo management, and enemy interaction.

A third-person camera system supporting scoped aiming for precision shooting.

A movement controller using Unity’s Rigidbody physics for grounded, camera-relative movement with a dynamic footstep system.

An InputManager that centralizes input handling and ensures smooth communication between all subsystems.

Systems in Detail:

​Player Movement System

The Character Controller-based movement system ensures smooth and responsive player control, supporting essential actions like walking, running, and transitions between animations. This system handles gravity and grounded checks to maintain stability and prevent unintended behavior, such as floating or falling through the ground. Below, you can find code snippets demonstrating how movement input is processed, gravity is applied, and the Character Controller is used to move the player character.

Player Combat System

The player can attack enemies using either melee or ranged systems, enabling dynamic and varied combat interactions. These attacks integrate seamlessly with the enemy AI health system by calling methods such as characterHitDamage() on the enemy side, ensuring damage is applied accurately when an attack connects. For example, when the player attacks a guard or boss, the system triggers the appropriate damage logic, reducing enemy health as intended. Below, you’ll find code examples that demonstrate how the player attack method works and how damage is applied through the characterHitDamage() function.

Player Detection System

The AI system uses Physics.CheckSphere to detect the player within a defined radius, employing layer masking for precise targeting. The player is identified either through the assigned tag or the specific playerBody GameObject in the AI code, which acts as the player’s physical representation in the game world. This setup allows the AI to accurately sense and respond to the player’s presence, triggering detection-based behaviors such as chasing or attacking. The detection logic ensures that only valid targets, like the player, are considered, maintaining performance and design intent. Below, you’ll find code snippets demonstrating how the AI detects the player using Physics.CheckSphere, layer masks, and the playerBody reference.

Player Feedback Systems

The player receives both visual and audio feedback when hit by enemy attacks. For example, when the AI’s ShootPlayer() method is called, it not only applies damage to the player but also instantiates a blood effect at the point of impact, providing immediate visual feedback that reinforces the intensity of combat. Audio cues, such as impact sounds or grunts, further enhance the immersion. When the player’s health reaches zero, a death sequence is triggered, playing specific animations and disabling player interactions to reflect the player’s defeated state. Below, you’ll find code snippets demonstrating the feedback loop where the AI’s ShootPlayer() method applies damage and spawns the blood effect to create a responsive and engaging combat system.

Player Interaction Systems

​The game features DeadBodyPick interactions, allowing players to loot or inspect bodies for valuable items and information, adding depth to exploration and strategy. This system ties seamlessly into a player inventory system, where looted items are stored and managed, such as health items, ammo, or special collectibles. The game’s UI feedback enhances player awareness, with visual indicators like health bars, ammo counters, and loot icons providing intuitive feedback during gameplay. Below, you’ll find screenshots of the UI in action, alongside sample scripts showcasing the interaction logic for looting bodies, inventory management, and UI updates.

image.png

AI Guard System

This code implements a patrolling guard AI with state-based behaviors walking, chasing, shooting, and dying built using Unity’s CharacterController for movement and raycasting for player interaction.

Core AI Behaviors Implemented

System

Patrol System

Player Detection

Chase & Combat

Health & Damage

Details

Guard follows a set of waypoints in a loop (forward/reverse). Smooth movement and rotation for natural patrols.

Vision-based detection using Physics.CheckSphere. Triggers alert states when the player is seen.

AI increases speed when chasing, stops to shoot at player using Raycast, respects cooldowns to prevent spam.

Guards take damage, enter alert mode, and die with animations when health reaches zero.

Systems in Detail:

AI State Machine

​Waypoint Patrol Logic

The AI guard patrols along a predefined set of waypoints, moving between them using linear interpolation via the CharacterController.Move method for smooth and controlled motion, while the rotation is handled through spherical linear interpolation (Slerp) for natural and fluid turning. Once the guard reaches the final waypoint in the sequence, the direction is reversed, creating a continuous patrol loop that maintains the guard’s presence throughout the level. While in the patrol state, the guard triggers a walking animation and plays footstep sounds, providing visual and auditory feedback that enhances the sense of realism in the environment.

in this image the Capsule are show as a repression of location that the ai uses as a waypoint system 

image.png

this video show the ai guard patrol system off. 

The AI patrols the environment by following a set of waypoints, using the currentWaypointIndex and movingForward flags to determine the patrol direction. When the AI reaches the end of the waypoint list, it reverses direction, creating a continuous and seamless patrol loop. To ensure smooth turning during patrols, the AI uses spherical linear interpolation (Slerp) for rotation, enhancing realism by mimicking natural movement.

Player Detection Logic

The AI system uses layer-based detection for flexibility, enabling specific filtering of objects like the player character within the environment. It differentiates behavior between chasing and shooting based on the player's distance, allowing for varied and responsive enemy interactions. The AI employs stateful logic using the isAlreted flag, which governs transitions between patrol, chase, and attack states, creating a layered and reactive system.

The AI employs sphere-based detection (via Physics.CheckSphere) to monitor the player’s presence within two critical radii: vision and shooting. When the player enters the vision radius but remains outside the shooting radius, the guard chases by calculating a normalized direction vector and moving towards the player. If the player enters the shooting radius, the guard stops moving, smoothly aims at the target using Quaternion.Slerp, and fires a raycast from a designated muzzle position (ShootingRaycastArea). Upon a successful hit, the guard applies damage to the player and spawns blood effects at the point of impact, enhancing visual feedback. A shooting cooldown is enforced using Invoke, ensuring the guard fires in controlled bursts rather than continuously.

Chasing Logic

When the player is detected within the guard’s vision radius but outside the shooting radius, the AI transitions to a chasing state. The guard calculates a normalized direction vector toward the player, multiplies it by its running speed, and moves using the CharacterController to maintain consistent physics behavior. Simultaneously, the guard smoothly rotates toward the player using Quaternion.Slerp for natural turning, and switches its animation state to running creating a dynamic and responsive chase that feels grounded and immersive.

The guard’s movement is driven by Unity’s CharacterController, ensuring consistent control across all AI states. The AI employs smooth rotation via Quaternion.Slerp, which allows it to fluidly turn toward its target, whether it’s a waypoint or the player. Animations are tightly integrated into the state machine walking during patrols, running when chasing, and shooting during combat enhancing immersion by visually matching AI behavior to its current state. This design creates a natural, believable movement system that bridges AI logic and player feedback.

Health System & Death Logic

Both AI guards and bosses utilize a health-based damage system that tracks incoming damage and triggers death upon reaching zero health. Once defeated, the AI transitions into a dead state, which includes playing specific death animations, disabling active components (like AI movement or NavMesh agents), and enabling DeadBodyPick functionality for interaction. This system ensures consistent combat feedback across different enemy types, blending gameplay logic with visual and interactive elements for a polished and cohesive experience.

The health system governs damage intake and death transitions across AI characters. Upon health reaching zero, the DeadBodyPick interaction system is activated, allowing players to interact with fallen enemies. The AI’s active behavior, such as patrol, chase, or shooting, is fully disabled after death to prevent unintended interactions or lingering behaviors. This design ensures a seamless blend between combat mechanics, visual feedback, and post-combat interaction, creating a more immersive and polished gameplay experience.

Code Challenges and Solutions

Guard Script Challenge and Solution

Managing Alert Transitions

Managing Alert Transitions was a core challenge during development, as it was essential for guards to smoothly transition between their patrol, chase, and shooting states based on the player’s proximity and level of alertness. Initially, guards would behave unpredictably, sometimes skipping states or getting stuck. To resolve this, I implemented a system of boolean flags such as isAlerted, playerInVisionRadius, and playerInShootingRadius which tracked the player’s position relative to the guard’s detection zones. These flags controlled the guard’s behavior transitions in a logical and predictable manner, ensuring that guards responded appropriately to player actions: patrolling normally, becoming alerted when the player entered their vision radius, and engaging in combat when the player moved within shooting range. This solution provided a clear and scalable system for managing guard state changes.

Preventing Rapid Shooting

Another key challenge was avoiding excessive shooting behavior when the player was within the guard’s shooting range. Without proper control, guards would rapidly fire in quick succession, overwhelming the player and breaking the intended combat flow. To address this, I introduced a cooldown system by implementing a previouslyShoot boolean flag, which temporarily disabled shooting after each shot. This flag was reset using Invoke, allowing a brief delay between shots and ensuring a more balanced combat experience. This approach not only prevented guards from spamming attacks but also introduced a natural pacing to their shooting behavior, creating opportunities for the player to react or escape.

Challenges In Game Development Overcome

I faced substantial challenges related to the gurad ai and npc walking. During the development of the Guard AI system for this project, I encountered several challenges related to creating a robust and functional waypoint traversal system and ensuring fluid AI behavior.

  1. Waypoint Traversal Issues:
    The initial implementation of the waypoint system had logical errors in how the AI handled switching between waypoints. Specifically, the logic for reversing direction when the guard reached the end of the waypoint list was flawed, causing the guard to get stuck. To resolve this, I carefully restructured the logic for updating the currentWaypointIndex to ensure seamless back-and-forth movement. I also introduced safeguards to prevent index out-of-bound errors and adjusted the proximity threshold for waypoint switching to improve responsiveness.

  2. Overshooting Waypoints:
    The guard would often overshoot waypoints due to an overly small threshold for detecting proximity to the target. By increasing the distance threshold and decoupling movement from rotation, I allowed the guard to approach waypoints more naturally while maintaining smooth rotations towards the target.

  3. Animation Synchronization:
    Ensuring that the walking animations matched the guard's movement was another key challenge. I updated the animation triggers (Run, Walk, and Shoot) in sync with the guard's movement state, ensuring a seamless visual experience during patrol.

  4. Directional Rotation:
    The guard's rotation occasionally appeared jerky due to incomplete handling of rotation vectors. To address this, I added a check to ensure the lookDirection vector was not zero before attempting rotation, resulting in smoother and more natural behavior.

  5. Debugging and Optimization:
    Debugging issues with AI state transitions and waypoint traversal required extensive testing. Using debug logs and visual gizmos, I identified and resolved areas where the AI logic was failing. This process also involved optimizing the movement and rotation updates for better performance and fewer redundant calculations.

Through these efforts, I was able to design a fully functional and polished AI patrol system. This not only improved gameplay immersion but also demonstrated my ability to overcome complex programming challenges, debug effectively, and implement scalable solutions.

  • Facebook
  • Twitter
  • LinkedIn

©2021 by Joseph Merrick. Proudly created with Wix.com

bottom of page