Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions BasicVirtualRealityDevelopment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,77 +14,77 @@

You will need to download and install the following software in the order provided.

### 1. [Visual Studio 2015 Community Edition](https://www.visualstudio.com/downloads/)
1. [Visual Studio 2015 Community Edition](https://www.visualstudio.com/downloads/)

Follow the link above and choose *Visual Studio Community* and follow the directions.
Follow the link above and choose *Visual Studio Community* and follow the directions.

### 2. [Unity 3D Daydream Technical Preview](https://unity3d.com/partners/google/daydream)
2. [Unity 3D Daydream Technical Preview](https://unity3d.com/partners/google/daydream)

Scroll down close to the bottom of the page to the download section. Download and install the latest release for your operating system. Make sure that *Android Build Support* is enabled as shown below.
Scroll down close to the bottom of the page to the download section. Download and install the latest release for your operating system. Make sure that *Android Build Support* is enabled as shown below.

![](./tutorial-pics/unity-android-support.png)
![](./tutorial-pics/unity-android-support.png)

### 3. [Google VR SDK for Unity](https://developers.google.com/vr/unity/download#google-vr-sdk-for-unity)
3. [Google VR SDK for Unity](https://developers.google.com/vr/unity/download#google-vr-sdk-for-unity)

Download this Unity package to a folder where it is easy to find later, for instance, your Desktop.
Download this Unity package to a folder where it is easy to find later, for instance, your Desktop.

### Additional Directions

Alternatively, you may follow the directions provided by Google [here](https://developers.google.com/vr/unity/get-started). Just note that we will not be using all of the components included in the Google VR SDK.
Alternatively, you may follow the [directions provided by Google](https://developers.google.com/vr/unity/get-started). Just note that we will not be using all of the components included in the Google VR SDK.

## Creating a Project

1. Start *Unity Daydream Preview*. Choose new project and give your project a name and a location.
1. Start **Unity Daydream Preview**. Choose new project and give your project a name and a location.

![](./tutorial-pics/unity-new-project.png)

## Setting the Build/Player Settings

1. Next, choose *Build Settings...* from the *File* menu.
1. Next, choose **Build Settings...** from the **File** menu.

![](./tutorial-pics/unity-build-settings.png)

2. Make sure that *Android* is selected, and then press the *Switch Platform* button in the bottom left corner.
2. Make sure that **Android** is selected, and then press the **Switch Platform** button in the bottom left corner.

![](./tutorial-pics/unity-switch-platform.png)

3. Next, press the *Player Settings...* button next to the *Switch Platform* button you pressed in the last step. This will cause the Player Settings to appear in the Inspector to the far right in the Unity editor. You can close the build settings window since we won't need it.
3. Next, press the **Player Settings...** button next to the **Switch Platform** button you pressed in the previous step. This will cause the Player Settings to appear in the Inspector to the far right in the Unity editor. You can close the build settings window since we won't need it.

![](./tutorial-pics/unity-player-settings.png)

4. Enable the *Virtual Reality Supported* checkbox. Then click the '+' to add a virtual reality SDK and select *Cardboard*.
4. Enable the **Virtual Reality Supported** checkbox. Then click the **+** to add a virtual reality SDK and select **Cardboard**.

![](./tutorial-pics/unity-player-settings-vr-supported.png)

5. Also make sure to change the *Bundle Identifier* and set the *Minimum API Level* to Android 4.4 (API level 19).
5. Also make sure to change the **Bundle Identifier** and set the **Minimum API Level** to Android 4.4 (API level 19).

![](./tutorial-pics/unity-minimum-api.png)

## Importing the Google VR SDK

1. Select *Assets->Import Package->Custom Package...* and then navigate to where you placed the *GoogleVRForUnity.unitypackage* file and open it.
1. Select **Assets** → **Import Package** → **Custom Package...** and then navigate to where you placed the `GoogleVRForUnity.unitypackage` file and open it.

![](./tutorial-pics/unity-import-package.png)

2. We won't be using the demos so uncheck the *Demos* checkbox and press the *Import* button.
2. We won't be using the demos so uncheck the **Demos** checkbox and press the **Import** button.

![](./tutorial-pics/unity-uncheck-demos.png)

## Create Folders for Later and Save the Scene

1. At the bottom left of the Unity editor is the project window. Select the top-level *Assets* folder. To create a folder, either right-click on the *Assets* folder itself, or in the right pane of the project window and select *Create->Folder*.
1. At the bottom left of the Unity editor is the project window. Select the top-level **Assets** folder. To create a folder, either right-click on the **Assets** folder itself, or in the right pane of the project window and select **Create** → **Folder**.

![](./tutorial-pics/unity-create-folder.png)

We will create three folders and name them *Scenes*, *Prefabs*, and *Scripts*.
We will create three folders and name them **Scenes**, **Prefabs**, and **Scripts**.

![](./tutorial-pics/unity-folders.png)

2. Finally, select *File->Save Scene* and save the scene as MyScene in the *Scenes* directory.
2. Finally, select **File** → **Save Scene** and save the scene as `MyScene` in the `Scenes` directory.

## Setting Up the VR View

1. In order to be able to see how the Cardboard app will look on the phone, we want to add a game object that will render stereo in the Unity editor game mode. To do this click on the *GoogleVR* folder in the project window. In the search bar (top right of the project window) type "gvrviewer". Drag the GvrViewer prefab from the project window to the hierarchy window.
1. In order to be able to see how the Cardboard app will look on the phone, we want to add a game object that will render stereo in the Unity editor game mode. To do this click on the **GoogleVR** folder in the project window. In the search bar (top right of the project window) type `gvrviewer`. Drag the GvrViewer prefab from the project window to the hierarchy window.

![](./tutorial-pics/unity-drag-gvrviewer.png)

Expand All @@ -94,15 +94,15 @@ Alternatively, you may follow the directions provided by Google [here](https://d

## Create the Ground Plane

1. In the hierarchy window right-click in a blank area and select *3D Object->Plane*.
1. In the hierarchy window right-click in a blank area and select **3D Object** → **Plane**.

![](./tutorial-pics/unity-create-plane.png)

2. Next, right-click on the new plane and rename it to "Ground".
2. Next, right-click on the new plane and rename it to `Ground`.

![](./tutorial-pics/unity-rename-ground.png)

3. Making sure that *Ground* is selected in the hierarchy window, edit the transform component in the inspector (upper right of the Unity editor) as shown below. Enter in zeros for all of the position and rotation components and (10, 1, 10) for the scale components.
3. Making sure that **Ground** is selected in the hierarchy window, edit the transform component in the inspector (upper right of the Unity editor) as shown below. Enter in zeros for all of the position and rotation components and (10, 1, 10) for the scale components.

![](./tutorial-pics/unity-ground-transform.png)

Expand All @@ -118,13 +118,13 @@ Alternatively, you may follow the directions provided by Google [here](https://d

## Box and Ball Prefabs

1. First, select the *Prefabs* folder down in the project window.
1. First, select the **Prefabs** folder down in the project window.

2. Next, right-click in the hierarchy window and select *3D Object->Cube*.
2. Next, right-click in the hierarchy window and select **3D Object** → **Cube**.

3. Drag the cube down into the Prefabs folder and rename it "Box".
3. Drag the cube down into the Prefabs folder and rename it `Box`.

4. Similarly, create a sphere in the hierarchy window, drag it down to the Prefabs folder, and rename it "Ball".
4. Similarly, create a sphere in the hierarchy window, drag it down to the Prefabs folder, and rename it `Ball`.

5. Delete the cube and sphere from the hierarchy window, but make sure to leave the prefabs.

Expand All @@ -134,7 +134,7 @@ Alternatively, you may follow the directions provided by Google [here](https://d

2. Next, edit the transform component so that when we drag new Box prefabs to the hierarchy view, they will show up at the origin. The position components should be set to (0, 0.5, 0) so that the Box rests on the ground plane. The rotation and scale components should be OK with the default settings.

3. Now, in the inspector click the *Add Component* button and select *Physics->RigidBody*. This will make it so that the Box can interact with other objects in the app.
3. Now, in the inspector click the **Add Component** button and select **Physics** → **RigidBody**. This will make it so that the Box can interact with other objects in the app.

![](./tutorial-pics/unity-add-rigidbody.png)

Expand All @@ -144,38 +144,38 @@ Alternatively, you may follow the directions provided by Google [here](https://d

1. Now we need to be able to throw balls at our blocks. Select the MainCamera in the hierarchy window.

2. In the inspector press the *Add Component* button, scroll down to the bottom of the menu and select *New Script* and name the script "ThrowBall".
2. In the inspector press the **Add Component** button, scroll down to the bottom of the menu and select **New Script** and name the script `ThrowBall`.

![](./tutorial-pics/unity-create-throw-script.png)

3. Next, in the new script component, right-click on the small C# icon, and select *Edit Script*.
3. Next, in the new script component, right-click on the small C# icon, and select **Edit Script**.

![](./tutorial-pics/unity-edit-script.png)

4. This should bring up Visual Studio with the file ThrowBall.cs in the editor.
4. This should bring up Visual Studio with the file `ThrowBall.cs` in the editor.

![](./tutorial-pics/vs-new-throw-script.png)

5. We need to make three new, public variables for our script to use.
* We need a RigidBody that will be our thrown ball. We'll call it **ball**.
* We need a Transform so we know where to throw the ball from. We'll call it **throwPosition**.
* We need a float to represent how hard we'll throw the ball. We'll call it **throwForce**.
* We need a `RigidBody` that will be our thrown ball. We'll call it `ball`.
* We need a `Transform` so we know where to throw the ball from. We'll call it `throwPosition`.
* We need a `float` to represent how hard we'll throw the ball. We'll call it `throwForce`.

![](./tutorial-pics/vs-add-throw-vars.png)

6. Remove the Start method, we won't be needing it.
6. Remove the `Start` method, we won't be needing it.

![](./tutorial-pics/vs-remove-start.png)

7. In the Update method, we need to create a ball and throw it if the button is pressed. Add the following code to the Update method.
7. In the `Update` method, we need to create a ball and throw it if the button is pressed. Add the following code to the Update method.

![](./tutorial-pics/vs-update-throw.png)

8. Finally, in the project window, select the top-level *Assets* folder. Then drag the ThrowBall script into the *Scripts* folder, just to keep things tidy.
8. Finally, in the project window, select the top-level **Assets** folder. Then drag the `ThrowBall` script into the **Scripts** folder, just to keep things tidy.

## Create a ThrowPosition Game Object
## Create a `ThrowPosition` Game Object

1. We need a position object to give our ThrowBall script so that it knows where to throw the ball. Since we want the ball to be aimed where we are looking, make an *Empty* game object that is a child of the MainCamera by right-clicking on the MainCamera and selecting *Create Empty*.
1. We need a position object to give our `ThrowBall` script so that it knows where to throw the ball. Since we want the ball to be aimed where we are looking, make an *Empty* game object that is a child of the MainCamera by right-clicking on the MainCamera and selecting *Create Empty*.

2. Rename the empty object "ThrowPosition".

Expand Down Expand Up @@ -257,4 +257,4 @@ Alternatively, you may follow the directions provided by Google [here](https://d

## PLAY!

Your game is now installed on your phone. Find it in your applications, start it, and put it into your Google Cardboard and play!
Your game is now installed on your phone. Find it in your applications, start it, and put it into your Google Cardboard and play!