Book Image

Mastering Oculus Rift Development

By : Jack Donovan
Book Image

Mastering Oculus Rift Development

By: Jack Donovan

Overview of this book

Virtual reality (VR) is changing the world of gaming and entertainment as we know it. VR headsets such as the Oculus Rift immerse players in a virtual world by tracking their head movements and simulating depth, giving them the feeling that they are actually present in the environment. We will first use the Oculus SDK in the book and will then move on to the widely popular Unity Engine, showing you how you can add that extra edge to your VR games using the power of Unity. In this book, you’ll learn how to take advantage of this new medium by designing around each of its unique features. This book will demonstrate the Unity 5 game engine, one of most widely-used engines for VR development, and will take you through a comprehensive project that covers everything necessary to create and publish a complete VR experience for the Oculus Rift. You will also be able to identify the common perils and pitfalls of VR development to ensure that your audience has the most comfortable experience possible. By the end of the book, you will be able to create an advanced VR game for the Oculus Rift, and you’ll have everything you need to bring your ideas into a new reality.
Table of Contents (17 chapters)
Mastering Oculus Rift Development
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Implementing 2D stereo audio


We'll begin by implementing the simplest form of game audio: two-dimensional stereophonic audio. We'll start with menu sound effects and then move onto music and classic ambient soundscapes.

The first thing we need to do is import some audio files into the project. Find the ButtonClick.wav and the ButtonHover.wav files included with this chapter and drag them into a new folder in your Project window called Audio. You'll know that they're valid audio files from their yellow waveform icon:

Note

Files with the .wav extension are one of the many supported audio file types in Unity. You can also import .mp3, .ogg, .aif, .mod, .it, .s3m, and .xm.

Next, we'll create a script that we can use to play these sounds when either of the buttons on the main menu are selected.

Playing a sound when a button is clicked on

Find the MenuCanvas object in your hierarchy and attach a new script named MenuSounds. Since both our START and QUIT buttons will make sounds, we're putting this...