A2 - Beat Saber

Goal

At the end of this assignment, you will create a clone of the popular VR game Beat Saber. A demo version of Beat Saber is available for free in the Oculus Store.

Solution

Here you can find the solution app. Download the .apk file and test it in the Quest for reference.

Additional Material

Point List (max 5 points)

  • Cubes are spawning (1 point)
  • Sabers collide with Cubes (1 point)
  • Add Ingame Debug console and print some information (1 point)
  • Extra Tasks

Instructions

In the following, you find instructions to build the assignment app. If instructions are unclear, refer back to the lecture material or post to the course forum. You earn the full points when your app is feature-complete; it does not need to be an exact copy of the reference app.

New Project

  • Unity 2022.3.8 LTS
  • Install also Android Package

Package Manager

  • Enable Show Preview Packages (probably not necessary anymore)
  • Install XR Plugin Management
  • Install XR Interaction Toolkit (2.4.3) and install Starter Asset

Add XR Interaction Setup

  • Add Prefab from Starter Asset

Add Plane

  • Right-Click -> 3D Object -> Plane

Configure Build

  • Edit -> Project Settings -> Player

  • Change Company Name

  • Change Product Name

  • Edit -> Project Settings -> Player -> Android Tab -> Other Settings

  • Change Minimum API Level to at least 30

  • Edit -> Project Settings -> XR Plug-in Management

  • Desktop Rider -> Enable Open XR

  • Android Rider -> Enable Open XR

  • Add interaction profile Oculus Touch Controller Profile (not the Meta Touch Controller!). Enable Meta Quest Support in Android.

  • Fix issues in the Project Validation

Build

File->Build Settings … Switch to Android - Switch Platform Add Open Scene Connect Quest Device Build and Run

Create App

Setup

  • Remove Rays from Hand Controller
  • Add Ingame Debug Window

Create Sabers

  • Make empty game object called Saber
  • Reset Saber position all to 0
  • Make Cylinder as children (of Saber) called Light
  • Scale to a long stick
  • Make Cylinder as children (of Saber) called Handle
  • Scale to shorter handle
  • Move Light and Handle in good positions
  • Rotate Saber such that the handle aligns with controller

Make Prefabs

  • Make Folder Prefabs
  • Drag Saber to Folder

Instantiate Prefabs

  • Drag Saber to Children of LeftHandController (same for right)

Add Colors

  • Make Folder Materials
  • Create Materials named Red and Blue
  • Adjust Albedo to color
  • Drag on object ‘Light’ in Sabers
  • Create Material named black and apply to ‘Handles’

Making BeatCubes

  • Create mid-sized Cube names BeatCubes
  • Create ‘CubeMovement’ Script
  • Make Folder ‘Scripts’ and move CubeMovement.cs files there (only for tidyness)
  • Edit CubeMovement
  • Add constant z-movement
  • Make Prefab
  • Make Prefab Variant for left and right with colors red and blue

Make CubeSpawner

  • Create Empty game object,
  • add Script ‘CubeSpawner’
  • Add BeatCube_Left as public variable in script
  • Instatiate Cube in Start routine, at the position of the spawner
  • Instantiate Cube in Co-routine (wait 1 seconds between each spawn)
  • Set public variable for spawn interval
  • Add probability of spawning with Random
  • Make Prefab
  • Add two CubeSpawners to Scene (with different colors and positions)

Hit Cubes

  • Add Script CubeHit to BeatCube prefab
  • Add OnTriggerEnter
  • Add Rigibody to BeatCube and enable ‘is Kinematic’
  • In Box Collider, enable ‘is Trigger’
  • Destroy gameObject
  • Check whether the correct colored cube was hit by comparing tags
  • Create Tags (red and blue)
  • Add Tags to BeatCube Left and Right Prefab, as well as ‘Light’ in Sabers
  • Compare Tags in OnTrigger

Add Music

  • Download track ‘fat rat’ (see above)
  • Make empty object ‘Music’ and drag in the sound file
  • Enable ‘Loop’ and ‘Play on Awake’ on Audio Source components
  • Make Cube Spawning musical: track BPM = 105. Thus, make spawning interval 60/105 = 0.571. Adjust spawning probability.

Build, Test and Submit

Extra Tasks

You can expand the gameplay by adding your own features. Points depend on quality of the features. Please explain all implemented features in a text file so we know what to look for.

Some ideas can be found here

  • Make cubes sometimes swap colors and destroy missed cubes (0.5 points)
  • Add lighting effects with glow, fog and postprocessing. (0.5 points)
  • Add cutting direction, e.g., by using the velocity (1 point)

Background Material

Here is an interview with Beat Saber’s developer Jan Ilavsky.

Credits

Some of material is inspired by this tutorial. You can use this video for more ideas. Note that versions are outdated and instructions might not be up-to-date.

Another great tutorial can be found here.

Previous