Simulation

The VR Boxing

Tools & Workflow:

  • XR Framework: Unity’s XR Interaction Toolkit for controller inputs and telemetry.
  • Asset Pipeline: Mixed store-bought assets (e.g., crowd animations) with custom shaders for divine effects.
  • Version Control: GitHub for collaborative C# scripting and scene management.

 

Game Overview: "Champion of the Gods"

Step into the arena and prove your worth to the divine.

Setting

You are a mortal champion chosen by ancient gods to battle in a supernatural boxing arena. Fight against formidable AI opponents in VR, wielding temporary divine powers granted by the gods. The goal is to defeat increasingly skilled foes in a stylized boxing ring surrounded by an ethereal crowd, culminating in a final showdown to earn your place among legends.

Core Mechanics

  • VR Boxing: Use Oculus Rift controllers to throw punches, block, and dodge with 1:1 hand tracking.

  • Supernatural Powers: Activate temporary abilities (e.g., time slowdown, enhanced strength, or shield) triggered by successful combos or divine favor.

  • Dynamic AI Opponent: A state machine-driven boxer that adapts to your playstyle—aggressive when you’re defensive, evasive when you’re relentless.

  • Ragdoll Physics: Realistic knockouts where enemies collapse dynamically, enhancing immersion.

Enemies & Progression

    • AI Boxers: Start with predictable rookies, progressing to agile, strategic champions who learn from your tactics.

    • Divine Trials: Each victory unlocks new powers or upgrades (e.g., longer ability duration, faster stamina recovery).

Development Cycle

  • After that, I changed the 3d character for the player to a first-person controller capsule. This was done for two things as a way to customise hit boxes. Furthermore, to add the camera, the player using a capsule is much easier, as we can place the camera.
  • In addition to replacing the arms of the 3D character with gloves, I believe this better represented the players in in-game hands and made the game more immersive.

PLAYER

  • Firstly, I needed to start up the project, so it had the Android build support module, which was essential for testing and implementing VR apps since it can be developed and operated on Android devices.
  • My first step in creating my game was to make the layout of the game. Using the Unity store, I sourced a 3D boxing ring. Once I had this, I downloaded two 3D characters with joints from Miximo to use as the characters the player would control.

XR Manager & XR Origin

  • The Unity XR Interaction Toolkit provides a framework that facilitates 3D and UI interactions through Unity input events. This system consists of a collection of foundational Interactor and Interactable components that the Interaction Manager organizes.
  • XR Origin serves as the basis for 3D and UI interactions, leveraging the input action manager.
  • The locomotion manager script is responsible for overseeing and controlling player movement within a virtual setting. It supports various movement types, including continuous movement, snap turning, and teleportation. In my game, we enabled the use of the Oculus Rift’s left controller joystick for player movements.

Gloves

  • Within the game, the left and right gloves contained the XR Controller, XR Ray Interactor, and the XR line visual.
  • These elements and scripts facilitated VR interaction and input from the Oculus Rift player’s hand, utilising the controller and gloves in the gameplay. This enabled the gloves to be a component in the game that can trigger an input in the game.
  • By employing the XR Controller, I was able to utilise the joystick on the left controller of the Oculus Rift for movement.

Scripts health

  • “Public health int”. At first, I used an integer to set a numerical value for the layer’s health level. The int was set to public so that I could amend the value in the Unity inspector if needed without opening the code.
  • I also made two ints, which were the (maxHealth) defined as the upper limit and the (currentHealth) which tracks the health and dynamically changes according to which damage received. These were also public as just test and debug. For tweaks and improvements.
  • At the start, the code sets the (maxHealth) to equal the function (SetMaxHealthFromHealthLevel), which in the private int is the health level. In the public void, take damage, we minus the (currentHealth) by the “damage”. If the (currentHealth) reaches 0, the animator plays a death animation
  • At the start, I made a script called player stats, which housed the values for the player’s health in the game. As each script had a sole purpose as the health bar was solely for UI.
  • Scalability & Maintainability as I intended to evolve the player stats script to store more attributes in the future, such as power-ups and enemy stamina. This was focusing on code best practices, as the core game logic was separate from the UI updates
  • Namespace simplifies the maintenance of large projects by grouping relevant functions. A namespace separates scripts that include classes with the same name (many classes, for example) to prevent conflicts.

Updated Health Script

  • Health Management Tracks max health (1000) and current health Has a health bar UI (Slider component) that updates dynamically
  • Damage System Takes 10 damage per hit (20 with double damage active) Detects collisions with “BoxingGlove” tagged objects Plays random punch sound effects on hit.

  • Blocking Mechanic  Blocks damage when the “isBlock” animation parameter is active. Triggers block particle effects instead of taking damage

  • Special Effect Particle system for blocked attacks Death animation trigger (“isDead” parameter) Sound effects for punches

  • Progression: Transitions to the “end win” scene when health reaches 0 Disables health bar UI on death Power-up Support: Double damage toggle system (controlled externally)

State machines AI logic

  • In my state machine logic, I made the state so that the enemy stays idle until it detects the player (canSeeThePlayer)
  • If the player is visible, it transitions to the chase state, in chase state, the enemy moves towards the player while adjusting its rotation
  • If it is within the attack range (distanceToPlayer <= attackRange), the state switches to the attack state.
  • From a predetermined selection of animations, the enemy launches random attacks.
  • tracks the conclusion of the animation using a coroutine before launching another assault.
  • If the player moves out of range, it transitions back to ChaseState.
  • Utilising and understanding how to make an AI boxing opponent.

Ragdoll Interactions

  • Body Part Management:
  • Uses the BodyParts enum for 11 essential body parts.
  • Details are stored in BodyPartInfo structs, including transforms, rigidbodies, and colliders.
  • Handles layer assignments for collision detection.
  • State Machine:
  • RagdollState transitions are: Animated ➔ Ragdoll ➔ Blend ➔ GettingUpAnim.
  • Manages hit reaction intervals and cooldowns.
  • Ragdoll Physics:
  • Calculates kinematic velocities.
  • Provides adjustable joint constraints, with default knees.
  • Applies forces to designated body parts.
  • Oversees parent-child dynamics among physics bones.
  • Animation Integration:
  • Validates humanoid avatars and regulates root motion.
  • Selects the correct getting-up animation based on facing direction.
  • Ensures smooth transitions between ragdoll and animation states.
  • Hit Reaction System:
  • Identifies hit zones, like the head.
  • Distributes force across body parts and sets hit tolerance thresholds.
  • Differentiates between partial and full ragdoll responses.
  • Key Workflows:
  • Initialization:
  • Validates the humanoid avatar’s legitimacy.
  • Establishes orientation for getting up.
  • Creates collider scripts and configures physical constraints.
  • Ragdoll Activation:
  • Disables the animator and applies forces to body parts.
  • Manages transitions between kinematic and dynamic states.
  • Blending Back:
  • Uses raycasts to evaluate ground position and selects the correct getting-up animation.
  • Ensures smooth position and rotation interpolation and reactivates root motion.
  • Hit Reactions:
  • Calculates impacts based on velocity and manages hit timings.
  • Distinguishes between partial and full ragdoll reactions in critical scenarios.

Other Similar Games

AR Pirate
AR Pirate Escape to the battle
Adventure
To Be Human
To be Human’ is a first-person sci-fi horror Made with Unity and Love for Ukie Game Jam 2024
3D Scifi
Project Asteroid
Embark on a thrilling adventure
Claim the highest score
Flight
flying game
Adventure
Movement Prototype
A prototype to showcase movement mechanics
Dungeon Shooter
Thrilling Dungeon experience
Action Adventure
Its Just a Game
In Development
Football, Simulation