Book Image

Unity Virtual Reality Projects - Second Edition

By : Jonathan Linowes
Book Image

Unity Virtual Reality Projects - Second Edition

By: Jonathan Linowes

Overview of this book

Unity has become the leading platform for building virtual reality games, applications, and experiences for this new generation of consumer VR devices. Unity Virtual Reality Projects walks you through a series of hands-on tutorials and in-depth discussions on using the Unity game engine to develop VR applications. With its practical and project-based approach, this book will get you up to speed with the specifics of VR development in Unity. You will learn how to use Unity to develop VR applications that can be experienced with devices such as Oculus, Daydream, and Vive. Among the many topics and projects, you will explore gaze-based versus hand-controller input, world space UI canvases, locomotion and teleportation, software design patterns, 360-degree media, timeline animation, and multiplayer networking. You will learn about the Unity 3D game engine via the interactive Unity Editor, and you will also learn about C# programming. By the end of the book, you will be fully equipped to develop rich, interactive VR experiences using Unity.
Table of Contents (15 chapters)

To get the most out of this book

Before we get started, there are a few things that you'll need. Grab a snack, a bottle of water, or a cup of coffee. Besides that, you'll need a PC (Windows or Mac) with Unity 2018 installed.

You don't need a super powerful computer rig. While Unity can be a beast that can render complex scenes, and VR manufacturers like Oculus have published recommended specifications for PC hardware, you can actually get by with less; even a laptop will do for the projects in this book.

To get Unity, go to https://store.unity.com, select Personal, and download the installer. The free Personal version is fine.

We also optionally use the Blender open source project for 3D modeling. This book isn't about Blender, but we'll use it if you want. To get Blender, go to https://www.blender.org/download/ and follow the instructions for your platform.

Access to a virtual reality head-mounted display (HMD) is strongly recommended in order to try out your builds and get first-hand experience of the projects developed in this book. Although not entirely required, you can use the emulation modes while working in Unity. Depending on your platform, you may need to install additional development tools. Chapter 3, VR Build and Run, goes into details of what you need for each device and platform, including SteamVr, Oculus Rift, Windows MR, GearVR, Oculus Go, Google Daydream, and others.

That should just about do it—a PC, the Unity software, a VR device, other tools described in Chapter 3, VR Build and Run, and we're good to go! Oh, some projects will be more complete if you download the associated assets from the Packt website, as follows.

Download the project assets and example code files

You can download the project assets and example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Unity-Virtual-Reality-Projects-Second-Edition. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

void Update () {
Transform camera = Camera.main.transform;
Ray ray;
RaycastHit hit;
GameObject hitObject;

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

 using UnityEngine;
using UnityEngine.Networking;
public class AvatarMultiplayer : NetworkBehaviour
{
public override void OnStartLocalPlayer()
{
GameObject camera = Camera.main.gameObject;
transform.parent = camera.transform;
transform.localPosition = Vector3.zero;
GetComponent<OvrAvatar>().enabled = false;
}
}

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."

Warnings or important notes appear like this.
Tips and tricks appear like this.