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, surrender commands, and a highlight system for planning and execution.
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, creating tactical opportunities.
- Knockout Interaction: Players can render enemies unconscious by hitting them over the head with a weapon when within range.
- 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: Implement context-sensitive interactions like knockouts and voice-command surrender, requiring precise spatial awareness.
- Solution: Knockouts trigger when the player is within a defined range and angle behind the enemy, calculated using the dot product of the player’s direction and the enemy’s forward vector. The surrender mechanic extends this logic with proximity checks and microphone input validation. Both mechanics integrate into the FSM, transitioning enemies into “unconscious” or “surrender” states.
3. Knockout & Surrender Mechanic
- Challenge: Implement context-sensitive interactions like knockouts and voice-command surrender, requiring distinct logic for each.
- Solution: Knockouts are collider-based and require a minimum velocity to trigger unconsciousness, ensuring the player must hit with sufficient force. The surrender mechanic needs the player to be behind the enemy and say “freeze” into the microphone (inspired by MGS), uses proximity checks and microphone input validation, calculated with the dot product of the player’s direction and the enemy’s forward vector for correct positioning. Both mechanics integrate into the FSM, transitioning enemies into “unconscious” or “surrender” states.
5. 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.
6. 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.
7. 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 hand 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 interactions in a VR context.