Bowling in VR
- Creating a simple bowling hall
- Grabbing the ball from a socket
- Physics of Pins including collisions
- Scoring and display
- Physics Material
- Interactive Audio
- Snap Turn and Teleporting
- Continuous Movement
- Character Controller
Here you can find the solution app bowling part. Download the .apk file and test it in the Quest for reference. Here you can find the solution app for the locomotion part. Please combine all features into a single app.
Point List (max 5 points)
- Ball can be thrown and slips nicely (0.5 point)
- Pins fall and make proper sounds (0.5 point)
- Scoring board counts (0.5 point)
- Teleport and Snap Turn with Left Hand (0.5 point)
- Continuous Movement and Turn with Right Hand (0.5 point)
- Cannot move through walls, but can crouch underneath (0.5 point)
- Extra Tasks
- Do not remove ray interactors
- Add ground plane. Make it long in z direction.
- Add two lane boundaries with cubes
- Add some colors
- Add XR -> Device-based -> Locomotion System
- Go to Locomotion System -> Snap Turn Provider -> Controllers: Set to size to 2
- Drag in LeftHandController to Element 0 and 1.
- Test snap turn with thumb stick.
- Add Teleportation Area component to floor
- Test teleportation with grip button
- Add Continuous Move Provider to Locomotion System. Configure Controller.
- Add Continuous Turn Provider to Locomotion System. Configure Controller.
- Disable Strafe on Continuous Move.
- Make Cube, set color and size
- Remove box collider
- Turn cube to prefabs ‘Hands’
- Put hands as Model Prefab to Left/RightHand Controller
- Make Sphere, set size and color
- Add Rigidbody and enable gravity
- Add XR Grab Interactable
- Make prefab
Distance Grab and Throw Ball
- RightHandController -> XR Ray Interactor -> Enable Force Grab
- Test grab with ‘grip’ button and throw ball
- Button can be changed in RightHandController -> XR Controller (Device-based) -> Select Usage
- Remove from LeftHand Controller: XR Ray Interactor, Line Renderer, XR Interactor Line Visual
- Add to LeftHand Controller: XR Direct Interactor
- Add to LeftHand Controller: Sphere Collider, set radius to 0.2, and enable ‘Is Trigger’
- Test direct grab
- (optional) Enable XR (Ray/Direct) Interactor -> Hide Controller on Select
- Make Cylinder, set size (e.g., 0.08, 0.2, 0.08) and color
- Add Rigidbody, set mass
- Make prefab
- Place ten pins
Make Table for the Ball
- Make Cube, place it at the side of the lane
- Place SocketInteractor on table: Create empty GameObject, add XR Socket Interactor, add Sphere Collider (enable is Trigger)
- Set Ball to XR Socket Interactor -> Starting Selected Interactable. The ball needs to be in the scene, not only a prefab.
Add Sounds for Pins
- Add to Pin Object: Audio Source Component and add pin impact sound file, disable ‘Play on Awake’
- Add to Pin Object a script “Impact Sound”
- Create variable AudioSource and connect component to script
- OnCollisionEnter play sound, (optional) use velocity to randomize volume and pitch
Add Physics Material to Ball
- Create Physics Material. Name it ‘Slip’.
- Set Dynamic and Static Friction to 0.1. Friction Combine to Minimum. Bounciness to 0.3.
- Drag Physics Material to Ball
Add Scoring Board
Add XR -> UI Canvas, Scale Canvas to (0.01,0.01,0.01), place canvas above pins
Add Text (Text Mesh Pro) to Canvas as a child. Name “Score”.
Add Script “Manage Score”. Open for edit
Add public function ‘IncreaseScore’ for counting the points
Add function ‘UpdateText’ for changing the Text in the Canvas (use score.ToString())
Add Script “PinFalling” to Pin
Add “using UnityEngine.Events;” to header
Create Unity Event
Invoke Unity Event on collision and if the pin is standing. (This is somehow inaccurate as the pin might not fall).
In Unity Editor, add Score to Pins’ unity event
- Add Background sounds, textures to objects (0.5 points)
- Spawn new bowling ball in Socket when the ball is removed (0.5 points)
- Add sounds to bowling ball (1 point)
- Add text when all pins fall over and reset pins (1 points)
- Add sound design when you move (0.5 point)
- Add Custom Recticle in Teleportation Area and change appearance XR Ray Interactor (0.5 points)
- Add tunneling vignette to continuous movement for comfort (0.5 point)
- Add a crounching mechanic, i.e., add a character controller in a way that the player has to crouch to reach a certain part of the world. (0.5)