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

Setting up VRHand to pick up objects

Now, we're ready to get our hands grabbing these objects.

Creating a function to find the nearest pickup object

The next thing we need to do is find out what objects are near enough to our hand to be picked up. Let's create a function to do this:

  1. In BP_VRHand, create a new function called FindNearestPickupObject.
  2. Set its Category to Grabbing and its Access Specifier to Private.
  3. In its implementation graph, right-click to create a Get All Actors with Interface node, and set its Interface value to BPI_PickupActor.

This is going to give us an array of every actor in the scene that implements the BPI_PickupActor interface.

  1. Drag a connector from the Out Actors output and create a For Each Loop node:

We're going to iterate through the actors that could possibly be picked up, ignore any actor that's too far to be considered, and then return the closest remaining eligible actor.

  1. From the For Each Loop Array Element output, drag out a connector and call Get Actor Location...