Tuesday, 26 May, 2020 UTC


Summary

Build your first VR game with Oculus Quest and Unity — Part 3 (Final)

Source
Welcome to the final part of this article series on building your first VR game with Oculus Quest, without writing a single line of code. If you have followed Part 1 and Part 2 until the end, your Unity window should look like below in Figure 1.
Figure 1
Now go to the Hierarchy panel and right-click on it and select 3D Object and Cube. Likewise, create 12 Cube objects and set the position and scale as shown below in Figure 2. (Faster way of doing this is after you create the first cube, while it is still selected, press Command + D to duplicate)
Figure 2
After you finish this, your scene should look similar to Figure 3 below.
Figure 3
Now let's create some balls to play. Again go to Hierarchy panel and right-click and select 3D Object and click on Sphere.

Trending AR VR Articles:

1. Designing for a modern 3D world: A UX design guide for VR
2. Scripting Javascript Promise In Spark AR For Beginners
3. Build your first HoloLens 2 Application with Unity and MRTK 2.3.0
4. Virtual Reality: Do We Live In Our Brain’s Simulation Of The World?
After that while sphere is selected go to the Inspector panel and click on Add Component and type Rigidbody to add a Rigidbody component to the sphere. (Optionally, in the Rigidbody component set the Mass to 3). After that click on Add Component once again, and type XR Grab Interactable to add the script. Refer to Figure 4 below.
Figure 4
Now let's duplicate (click on sphere object and press command + D or right-click and select duplicate)the sphere to add two other spheres. Set the position and Scale as in Figure 5 below.
Figure 5
After you finish this, your scene should look similar to Figure 6 below.
Figure 6
Now go back to the Hierarchy panel and select both Right_Controller and Left_Controller objects. While both the objects are selected, go to Inspector panel and click on Add Component and type Sphere Collider and click on it. And tick on IsTrigger checkbox and asset radius to 0.1. After that, again click on Add Component and type XR Direct Interactable and add it. Refer to Figure 7 below.
Figure 7
Next, let's add some bowling pins. In the Project panel, go to Asset folder -> Bowling Kegel & Ball folder -> Prefabs folder. Click and Drag Kegel Prefab to Hierarchy panel. Right-click on it and select Unpack Prefab Completely. Expand the Kegel object and select the child object and change the Scale to X:0.2; Y:0.2 and Z:0.2. Click and drag the 'White' material that we already created in the previous article (Part 2). Then click on Add Component and add a Rigidbody and again click on Add Component and add Capsule Collider. Duplicate Kegel child object 6 times. Refer to Figure 8.1, 8.2 and 8.3. and change the position as below in Figure 9 (parent Kagel object) and Figure 9.1 (Each child Kegel object) (Please excuse my bad object naming here) After that, select that parent Kegel object and duplicate that once and change the position as in Figure 10.
Figure 8.1Figure 8.2Figure 8.3Figure 9Figure 9.1
Once, you position these bowling pins and duplicate the whole parent Kegel object and change its position as shown in Figure 10 below.
Figure 10
Well, now we finished all the functionality of our Six-pin bowling game. Let's add some colours to make it look nicer. In the previous article, I mentioned how to create a material and apply that to an object. In Figure 11 below, this is illustrated once again.
Figure 11
Create some colourful materials and add them to the spheres and cubes to make them look nicer. See Figure 12 below to see the colours and materials that I have added.
Figure 12
Alright! Time to deploy the games to Oculus Quest. This is the easiest part. Firstly, make sure that the developer mode is on in your Oculus Quest. (If you are not sure I recommend to read my very short Article on how to enable developer mode on Oculus Quest). After that, connect your USB Type C cable to your MacBook or to your PC. Then, go to File -> Build Settings…, Double-check, whether you have added the correct scene (In our case BowlingGameScene) and selected the correct platform, which should be Android. Well, next is to click Build and Run. You will be asked to select a folder. Create a new folder anywhere you like and give a name to your build file. That's it. It will build the code and automatically deploy the game into your Oculus Quest. You will then see a pop-up in your Oculus. Confirm it and start playing.
If you wonder where it will be inside the Oculus, go to Library -> Unknown Sources, and you will see your game.
Here's a small video capture of the gameplay.
That is it! I hope you enjoy the article and start building exciting VR games. All the best!!
If you want to thank me or if you like this article;
Cheers!

Don’t forget to give us your 👏 !

https://medium.com/media/1e1f2ee7654748bb938735cbca6f0fd3/href
Build your first VR game with Oculus Quest and Unity — Part 3 (Final) was originally published in AR/VR Journey: Augmented & Virtual Reality Magazine on Medium, where people are continuing the conversation by highlighting and responding to this story.