VR Stealth Shooter
April, 2020
A tactical VR sandbox prototype for Oculus Rift S, featuring stealth mechanics, modular AI, weapon systems, physics-based explosives, and tactical features like knockouts and surrender commands.
Introduction
- Overview: VR Stealth Shooter is a sandbox game prototype that combines stealth mechanics, responsive AI, and immersive VR interactions. Developed for the Oculus Rift S in Unity, it offers a sandbox for players to experiment with weapons, tactics, and AI in a basic tactical VR experience.
- Motivation: This project aimed to explore how classic stealth mechanics could be adapted to VR, leveraging the platform’s immersive potential while experimenting with AI behaviors, physics, and player interactions.
Key Features
- Stealth AI: Enemies switch between idle, patrol, search, attack, and reload states based on their vision and hearing.
- Weapons: Includes a semi-automatic pistol, fully automatic rifle, and grenade, with toggleable silencers for stealth play and limited ammo capacity, with realistic bullet shell ejection.
- Physics-Based Explosives: Grenades can be used strategically, either thrown or launched into the air through interactions with the environment, detonating on a timed countdown, affecting other physics-based objects such as launching nearby enemies into the air as ragdolls.
- Explosive Chain Reactions: Barrels and grenades can ignite cascading explosions.
- Knockout Interaction: Players can render enemies unconscious by hitting them over the head with a weapon.
- AI Cover Behavior: Enemies seek cover dynamically while reloading to avoid exposure.
- Voice Commands: Players can force enemies to surrender by saying “freeze” into the microphone while positioned close behind them.
- Ragdoll System: Enemies react realistically upon neutralization, transitioning into ragdoll states.
- Highlight System: Enemies can be highlighted through walls to assist with tactical planning.
- Player Controller: Provides teleportation, object grabbing, and weapon interaction in VR.
Key Challenges & Solutions
1. Modular AI Design
- Challenge: Develop a scalable AI architecture for reactive behaviors and future expansion.
- Solution: Implemented a finite state machine (FSM) with modular states (idle, patrol, chase, search, reload, death) triggered by game events or sensory inputs. Integrated Unity’s NavMeshAgent for pathfinding and raycast checks for advanced behaviors like line-of-sight and cover detection.
2. Weapon Interactions
- Challenge: Implement realistic weapon mechanics with support for silencers and ammo limits.
- Solution: Created a modular weapon system with shared base functionality for firing, reloading, and ammo tracking. Silencers dynamically adjust sound propagation to enemy hearing systems. Added physics-based bullet shell ejection for enhanced visual realism.
3. Knockout & Surrender Mechanic
- Challenge: Creating immersive mechanics like knockouts and voice-activated surrender required precise spatial awareness and audio input integration.
- Solution: Knockouts trigger when the player strikes an enemy’s head collider with sufficient velocity. The surrender mechanic requires sneaking up behind an enemy undetected, verified using the dot product of the player’s direction and the enemy’s forward vector. Saying “freeze” into the microphone triggers an event causing the enemy to surrender, raising their arms in response. Both mechanics integrate into the enemy FSM, transitioning enemies into “unconscious” or “surrender” states.
4. Vision System Implementation
- Challenge: Efficiently detect targets within an enemy’s field of view.
- Solution: Used a
SphereCollider
to detectIDetectable
objects in range and forming a field-of-view flat cone by calculating the angle between the enemy’s forward vector and the target’s direction. A raycast confirms line of sight, ensuring targets within the FOV cone initiate a pursuit state.
5. Physics-Based Explosives and Chain Reactions
- Challenge: Design interactive explosives with dynamic behavior and environmental interconnectivity.
- Solution: Grenades feature physics-based interactions, reacting dynamically to external forces like gunfire, enabling creative trickshots. Chain reactions occur when overlapping colliders detect the blast radius of nearby explosives. Detonations apply forces to nearby objects using
Rigidbody.AddForce
, creating realistic and dynamic environmental interactions.
6. Ragdoll and Animation Systems
- Challenge: Blend animations with reactive ragdoll physics for realistic enemy falls upon neutralization.
- Solution: Used RootMotion PuppetMaster to transition smoothly between animations and ragdoll physics. FinalIK ensured precise weapon pose alignment across different animations.
Future Development
- Enhanced Enemy AI: Expanding AI behaviors to include coordinated group tactics and dynamic environmental interactions.
- New Weapon Types: Introducing additional weapons with unique mechanics, such as sniper rifles or shotguns.
- Objective-Based Missions: Adding structured objectives for players to complete.
- Multiplayer Support: Exploring cooperative and competitive modes to expand the gameplay experience.
Key Takeaways
This prototype showcases stealth mechanics, responsive AI, and immersive VR interactions. It highlights advanced use of Unity’s tools, including AI state management, NavMesh navigation, and physics-driven gameplay. The modular design and scalable systems make it a strong foundation for future iterations, emphasizing creative problem-solving and dynamic stealth interactions redesigned in a VR context.