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)
- Cubes are moving musically (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 2019.4.40 LTS
- Install also Android Package
Package Manager
- Enable Show Preview Packages (probably not necessary anymore)
- Install XR Plugin Management
- Install XR Interaction Toolkit (2.1.1)
Add XR Origin
- In the Scene Hierarchy - Right-Click -> XR -> Device-based -> XR Origin
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 23
Edit -> Project Settings -> XR Plug-in Management
Desktop Rider -> Enable Oculus
Android Rider -> Enable Oculus
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 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
- Make cubes sometimes swap colors and destroy missed cubes (0.5 points)
- Add lighting effects with glow, fog and postprocessing. Some ideas can be found here (0.5 points)
- Add cutting direction, e.g., by using the velocity (1 point)
- Add slicing in half animation. Here is a more involved tutorial. (1 point)
- Add your own feature including explanation in the text file (up to 1 point each)
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 is can be found here.