TL;DR: I’m building a VR mech game with Unreal Engine 4. It has been surprisingly simple to nail down realistic physics and intuitive controls with constraints to limit nausea. See the video at the end of the article.
I’ve worked with VR for the last 2 years in the context of 360 videos, so I’ve been able to keep an eye on the industry. VR has been getting buzz for a few years now, but it’s finally at a point where I think it’s viable to invest in it from both a developer and consumer standpoint.
In May 2017, I went to a Unity-sponsored VR conference. I saw many companies, many headsets and many interactive experiences. Microsoft sent me a free Asus Mixed Reality Headset. Unfortunately the headset was buggy and unusable, so I decided to invest in a more mature platform such as the Oculus Rift or HTC Vive. The Rift was the cheaper choice, and I’ve got a developer-crush on John Carmack (CTO of Oculus), so it was a no-brainer. The new headset arrived in the mail a few days ago.
Exploring VR Experiences
There are some awesome VR games out there right now. The most inspiring for me is Elite Dangerous. You don’t really comprehend the vastness of space until you’re surrounded by stars and occasionally face-to-face with one. VR and cockpits go together like PB&J. This game has shown me how anchoring the player’s peripheral is a key factor for comfortable gameplay.
Another fun game is Serious Sam 3 VR. Blasting countless foes into little giblets is much more immersive when you get to hold the guns and do it yourself. Though I’m not a big fan of the teleportation technique for movement, I do understand the reasoning behind it. You can’t just convert any standard FPS game to a VR game because the brain gets funky when your head is moving without your consent. Dizziness, headaches and vomiting are a very real possibility.
Aside from the made-for-VR games, I also tried out some good old fashion PC games using an app called Bigscreen that sits you in front of your own theatre-sized desktop. One thing I quickly realized about VR is that it’s very demanding on your hardware. I’ve got a gaming laptop with a GTX 1060, quad core i7 @ 2.8ghz and 16GB RAM. While it’s enough to max out just about any game out there at 1080p, running a game in VR is the equivalent of running on two 1080p monitors- one for each eye. And since head tracking must remain smooth at all times, the recommended framerate is 90fps. That means my GTX 1060 is basically the minimum spec for a smooth and visually pleasing VR experience.
Getting My Hands Dirty
Before digging into the game engine, I needed an idea to guide my decisions. Ever since I played Mech Warrior on PC many eons ago, I’ve been a fan of the concept. A huge machine standing thousands of meters high with machine guns and heat-seeking missiles… It’s an awesome concept that has yet to reach it’s full potential. VR has been the missing ingredient. So there was the idea.
Then I had to choose between Unity and Unreal Engine. Unity has an awesome community and very good cross-platform support. But UE4 has that stuff too, in addition to superior out-of-the-box graphics that can be borderline photorealistic at times. Additionally, the Blueprint system seemed like a nice approach to hashing out the game logic. It was a choice that I certainly don’t regret.
Ultimately, my goal at this stage was to be able to fly around an environment. This would require realistic physics to handle momentum and thrust. Implementing that was as simple as enabling the checkbox labeled “Simulate Physics” for a static mesh, then having the camera be a child of that mesh. Now our character will fall and react to other forces. To be able to fly would require adding a Physics Thruster which is the equivalent of a jet pack. I then used the Blueprint system to map the controller’s left trigger axis value to the thruster’s strength and BOOM, liftoff. Seperate thrusters were added to accommodate for each direction the character would move and rotate. This was a ridiculously intuitive approach to handling physics because it models after real life inputs rather than some arbitrary line of code that says “set my position to my last position plus X units”.
As far as controls, all the major VR headsets come with one controller for the left hand and and another for the right. Together, they feel similar to holding a traditional console controller since they have triggers, analog sticks and face buttons. I decided to have the left controller be responsible for movement and the right controller handle perspective and attacks. Most games already do this. I also decided to constrain the cockpit rotation so that it only rotates around the yaw axis (left and right) so that our sense of up and down never changes, which makes for a comfortable experience even when you’re jetting around the map.
Here’s the results: