Unreal Engine Part 16: VR motion controllers


In chapter 16 of Rob Redman's comprehensive introduction to Unreal Engine, learn how to set up your controllers for use in virtual reality...

Previous tutorials
Part 1: Setting up a new project
Part 2: Introducing materials and landscapes
Part 3: Adding foliage and rocks
Part 4: Particle smoke
Part 5: Introducing the skybox
Part 6: Setting up cameras and post-effects
Part 7: Teleporters
Part 8: Adding random assets
Part 9: Destruction
Part 10: Adding sound
Part 11: Linking audio to actions and objects
Part 12: Using the matinee tool
Part 13: Lighting
Part 14: Post effects
Part 15: Virtual reality
In the last chapter I tried to give you some ideas to get you started thinking about VR experiences, and how to think about things in a slightly different way. But you need to be able to put that into practice, so in this chapter I'm going to show you how you can set up your motion controllers, so if you have a PS Move, or a Rift controller, then you will be able to use them in your levels. I'm going to set up a simple control using Steam VR, as that's what I prefer to use, with the HTC vive.
The process I'm going to show is a very simple one but when combined with other tools and techniques I've described in other chapters becomes powerful, and helps the player to engage with the world built for them.
I'm not going to talk about what the controls should be used for - that's for you to choose - but I will say that if you've ever wanted to paint in 3D space and be able to walk around and through your art, then pop an emitter on the end of your controller and start waving it about, to paint with particles.
Very rewarding indeed.
Step 01: Static Mesh
Although you can use any geometry to represent the controls it's usually nice to have something that works for the intended use, like a paintbrush for the idea I previously mentioned, or a wand for a wizard, and so on. For this example, I'm showing you how to get started with motion controllers, so I modelled a very basic and generic controller, the FBX file for which should be included with this chapter, should you wish to use it.
It doesn't matter what software you use to model the asset, as long as you can export an FBX file. I used CINEMA 4D to do mine.

Modeling an object to be your controller in the level makes a lot of sense.
Step 02: Import
With your assets built you need to get them into Unreal Engine, as static meshes. All you need to do is click Import in your content browser and navigate to them on your hard drive. The FBX file should import perfectly and be ready to go but if not, make sure you are just importing the geometry. If you are using the latest FBX version it can, now and then, give some errors, so try using an older format if you have issues.

)Get your assets in and keep an eye on the scale.
Step 03: Blueprinting
The initial setup is really very easy indeed. The developers have seen the need for a good workflow and made it incredibly easy. First thing to do is open up your player's blueprint. You can do this by right-clicking it in the Outliner, and choosing edit, or selecting it in the viewport and hitting Ctrl+E. If you don't have a player pawn, then you can get one from the default content in the FirstPersonBP folder.

The blueprint has a lot in it but ignore it!
Step 04: Adding controllers
You need to get your controls into the blueprint, so, in the components section click Add Components and from the drop-down choose a static mesh. Name this Left, or something similar, then repeat for the right-hand side. In the details tab for each, specify the imported FBX and choose a material, if you didn't apply one to the mesh itself.

Set up a mesh for each side, with a material if needed.
Step 05: Chaperone
The Stem VR implementation has a neat node that takes care of things for you. All you need to do to get everything up and running now is add a SteamVRChaperone. That's it. All done. You won't see anything in the viewport to start with but once you plug in your controllers and start moving them, the meshes will appear!

A small collection of nodes is all that's needed to get you started.
Step 06: Events
Although I'm not going to show you how to set up the controllers to do specific tasks, I will just point out a good place to start. If you look in the details tab you will see, at the bottom, a list of events. You can use these to set up your first interactions. Some are more useful than others but be imaginative and you won't go far wrong.

A small collection of nodes is all that's needed to get you started.
Top tip: Poly count
It may sound obvious but keep your polygon counts reasonable. VR has more to deal with than a standard game level and anything you can do to help will be worth it.
Related links
Part 1: Setting up a new project
Part 2: Introducing materials and landscapes
Part 3: Adding foliage and rocks
Part 4: Particle smoke
Part 5: Introducing the skybox
Part 6: Setting up cameras and post-effects
Part 7: Teleporters
Part 8: Adding random assets
Part 9: Destruction
Part 10: Adding sound
Part 11: Linking audio to actions and objects
Part 12: Using the matinee tool
Part 13: Lighting
Part 14: Post effects
Part 15: Virtual reality
Buy a copy Unreal Game Engine
Download Unreal
Fetching comments...