Book Image

Unreal Engine 4 Virtual Reality Projects

By : Kevin Mack, Robert Ruud
Book Image

Unreal Engine 4 Virtual Reality Projects

By: Kevin Mack, Robert Ruud

Overview of this book

Unreal Engine 4 (UE4) is a powerful tool for developing VR games and applications. With its visual scripting language, Blueprint, and built-in support for all major VR headsets, it's a perfect tool for designers, artists, and engineers to realize their visions in VR. This book will guide you step-by-step through a series of projects that teach essential concepts and techniques for VR development in UE4. You will begin by learning how to think about (and design for) VR and then proceed to set up a development environment. A series of practical projects follows, taking you through essential VR concepts. Through these exercises, you'll learn how to set up UE4 projects that run effectively in VR, how to build player locomotion schemes, and how to use hand controllers to interact with the world. You'll then move on to create user interfaces in 3D space, use the editor's VR mode to build environments directly in VR, and profile/optimize worlds you've built. Finally, you'll explore more advanced topics, such as displaying stereo media in VR, networking in Unreal, and using plugins to extend the engine. Throughout, this book focuses on creating a deeper understanding of why the relevant tools and techniques work as they do, so you can use the techniques and concepts learned here as a springboard for further learning and exploration in VR.
Table of Contents (20 chapters)
Title Page
About Packt
Where to Go from Here


Virtual reality (VR) isn't just the media we knew and loved from the twentieth century in a stereo headset. It's much more than that. VR doesn't simply show us images of the world around us in stereo 3D. In a literal sense, sure, that is what it does, but that's a little like saying that music just wiggles the air around our ears. Technically true, but too reductive to let us understand it. VR plays with our senses and dances with the cognitive mechanisms by which we think we understand the world. To get VR and learn how to create for it, we have to accept that it is an entirely new medium, and what we don't know about its language, rules, and methods far outweighs what we do know. This is powerful stuff, and, without question, VR or some variant of this technology is likely to be the defining art form of the twenty-first century.

You'd be right to greet this assertion with a bit of skepticism. Given the present state of the technology and of the industry, it takes some imagination to see beyond the horizon of where we are now. And you've probably seen by now that the public's expectations are in a race with the actual state of the technology and the art form. Sometimes, they lag behind its reality, and sometimes they jump ahead. Opinions about VR, therefore, are all over the place. If we're in one of those phases where the tech makes a leap forward, people get amazed and excited by the possibilities and the breathless blogs declare that the world has changed. If we're in one of those phases where the expectations have jumped ahead, suddenly everyone's disappointed that their first-generation Oculus Rift hasn't morphed overnight into the Holodeck and we see a lot of disillusionment on blogs. It's impossible to predict where the pendulum will be in its swing when you read this.

Here's the reality though, and why we believe this medium is worth learning now: VR is coming, it's inevitable, and it changes everything, even if this isn't yet obvious from the rudimentary state of the first-generation technology. This medium carries with it the potential to revolutionize the way we learn, play, engage the virtual world, and so much else. But it's going to take time and imagination.

VR is a medium at a crossroads. The decisions we make now are going to carry us far into the future. The developers working in this medium will be the ones to shape its language and methods for the next generation. To work in VR is to work on a frontier, and that's an exciting place to be.


In this book, we intend to give you a solid set of tools to begin your work on this frontier. This book uses a practical, hands-on approach to teach you how to build VR games and applications using the Unreal Engine. Each chapter walks you step-by-step through the process of building the essential building blocks of a VR application, and we pair these steps with in-depth explanations of what's really going on when you follow them and why things are done the way they are. It's this why that matters. Understanding how the underlying systems and ideas work is crucial to the work you'll do on your own after you've finished these tutorials, and, in this book, we've tried to give you both—an understanding of what to do to build a VR application, and the background you'll need in order to use this book as a springboard for your own work in VR.

You should come away from this book with a solid understanding of how VR applications are built, and what specifically you need to know and understand about the Unreal Engine to build them. It's our hope that the work we do together here will set you up to take your exploration into this new frontier wherever you want to go.

Who this book is for

If you're interested in creating VR games or applications, interested in seeing how VR could augment the work you do in your current field, or are just interested in exploring VR and seeing what it can do, this book is for you. You don't have to be an experienced engineer or even deeply experienced with Unreal Engine to benefit from this book; we explain everything as we go. Readers who are entirely new to Unreal Engine will find it helpful to run through Epic's getting started tutorials before diving in here, just so you know where everything is, but this book is entirely appropriate for both experienced Unreal users who need to learn specifically how Unreal works with VR, and for new Unreal users just finding their way around.

Whether you're entirely new to VR development and to Unreal, you've already been working in VR in another engine, or you know your way around Unreal but are new to VR, this book should be able to provide a lot of value. (And we hope even those already well versed in VR creation using Unreal Engine find a few interesting new perspectives and techniques as well.)

What this book covers

Chapter 1, Thinking in VR, introduces VR as a medium and discusses a few of the many ways it can be used in a number of fields. We discuss the crucial concepts of immersion and presence, and outline practices for designing and building effective VR experiences.


Chapter 2, Setting Up Your Development Environment, takes you through the process of setting up Unreal Engine and setting up to develop for mobile VR, and talks about where to learn about using Unreal and where to get help. For those interested in working in C++, this chapter also shows how to set up your development environment to build C++ projects and to build Unreal Engine from source code.

Chapter 3, Hello World: Your First VR Project, shows you how to create a new VR project from scratch, what settings to use when creating for VR and why we use them, and what you need to do differently if you're building for mobile VR. This chapter also teaches you how to get content into your project and work with it, and how to set up a few of the basic blueprints you'll need for VR development.

Chapter 4, Getting Around the Virtual World, teaches you how to create and refine navigation meshes for character locomotion, how to build a player-controlled character and set up input handling, and then shows how to build a teleport-based locomotion scheme and how to implement seamless movement for a more immersive VR experience.

Chapter 5, Interacting with the Virtual World - Part I, shows you how to add hands to the player-controlled character and use hand-held motion controllers to drive them.

Chapter 6, Interacting with the Virtual World - Part II, shows how to set up an animation blueprint to animate the player's hands in response to input, and how to make it possible for players to pick up and manipulate objects in the world.

Chapter 7, Creating User Interfaces in VR, shows you how to create interactive 3D user interfaces for VR, and introduces an AI-controlled companion character to be controlled by this interface.

Chapter 8, Building the World and Optimizing for VR, teaches you how to use the Unreal Editor's VR Mode to build environments from within VR, and how to find performance bottlenecks in your environment and fix them.

Chapter 9, Displaying Media in VR, teaches you how to display video media on virtual screens in VR space, in both mono and stereo. You'll learn how to put 2D and 3D movies onto traditional virtual screens, how to surround the player with 360-degree mono and stereo video, and how to create a media manager to control its playback.

Chapter 10, Creating a Multiplayer Experience in VR, teaches you about Unreal's client-server network model, and shows you how to replicate actors, variables, and function calls from the server to connected clients, how to set up a player character to display differently to its owner and to other players, and how to set up remote procedure calls to trigger events on the server from clients. 



Chapter 11Taking VR Further - Extending Unreal Engine, shows you how to install and build plugins to extend the engine's capabilities, and how to use Blueprint's powerful debugging tools to dig into unfamiliar code and understand it.

Chapter 12Where to Go from Here, shows you where to get further information as you dive deeper into VR development.

Appendix AUseful Mind Hacks, leaves you with a number of useful mind hacks to make your development more effective.

Appendix BResearch and Further Reading, provides a few useful starting places for your search that will gradually help accelerate your learning enormously.

To get the most out of this book

You don't need to be an expert Unreal developer to benefit from this book, but it is helpful to have a sense of where things are. If you haven't yet installed Unreal Engine, don't worry—we'll cover this in Chapter 2, Setting Up Your Development Environment, but if you've never used it before, it may be helpful at that point to take the time to run through the Unreal getting started tutorials before diving back into this book just so you know where everything is.

All of the projects in this book have been designed to work with the Oculus Rift and HTC Vive minimum specs, so whether you're on a desktop or a laptop, you should be fine provided your system meets these minimum specs. You should, of course, have a VR headset available, and if you're planning to develop for mobile VR, it's still recommended that you have a desktop VR headset available as well, since it will make testing dramatically easier. All of the software you'll be using through the course of this book is freely available online and we'll walk you through downloading and installing it, so there's nothing special you need to have installed on your system before we begin.

This book is primarily written with PC developers in mind, but if you're working on a Mac, your development environment setup will be different, but everything we do in the engine will work the same way.

So that's it. If you have a VR headset, a system that can run it, and internet access (since we'll be downloading the engine and example content), you have everything you need.

Download the example code files

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit 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
  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 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 Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here:

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: "We should take a quick look at your project's .uproject file as well."

A block of code is set as follows:

html, body, #map {
 height: 100%; 
 margin: 0;
 padding: 0

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

exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

Any command-line input or output is written as follows:

UE4Editor.exe ProjectName ServerIP -game

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 Window | Developer Tools | Device Profiles to open the Device Profiles window."


Warnings or important notes appear like this.


Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit


Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit