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

Synchronizing data in multiplayer matches


Everything that you've done up to this point has been about getting players in the same match, but we haven't covered anything about keeping in-game events synced between the server and client. Fortunately, Unity's networking API makes this very easy; we can use most of the code we've already written with some slight modifications to make it network-aware.

Syncing player movement

The first thing we'll tackle is player movement, so you can see other people walking around the map. We'll build upon our existing player prefab and the NetworkIdentity component, as well as a new kind of component: NetworkTransform.

Select the ArenaPlayer prefab in your Project window and add a NetworkTransform component in the Inspector. This alone is enough to sync the position across the network but, if you tested now, you'd run into an interesting problem: input from any player would be reflected on every other player instance in the game. This is because there's one instance...