Quickstart Guide to Oculus Quest 2 and Unreal Engine 4
Getting started with virtual reality
I recently acquired an Oculus Quest 2, which is a pretty amazing piece of hardware.
I’m a software engineer and gamer. Before this, I had never used VR, but obviously had seen many examples of Unreal’s Engine in many games. I enjoy programming and have several visual ideas that I would like to see in VR. I’ve learned that the two main frameworks used by most VR devices are Unity or Unreal. I picked Unreal since it is based on C++, and I already have a background in that language.
Excited to try writing my first VR programs, I worked my way through several quick start guides online, but didn’t find any that worked with the Quest 2. Although there are several guides for the Oculus Quest and for Unreal Engine 4, none were comprehensive or up to date enough to get me started. The most complete guide I found was here:
This guide, written by Oculus, covers how to get started with the Oculus Quest (1) and it’s well worth the read to get a general idea. Unfortunately Oculus doesn’t have a new guide for the Quest 2, and the Quest 1 guide above does not list the correct versions of software for the Quest 2, Unreal Engine, and even for the general setup.
So, after much research and experimentation, I’ve collected my lessons learned below to help others get started faster.
Tip 1: Use Android Studio to get Android SDK 29 and NDK 21.3
Many of the outdated guides recommend Android API version 24, but the Quest 2 is Android OS 10, so you should use version 29. If you missed the Android Studio setup in the quick start guide, look here:
Selecting the version of the Android Software Development Kit (SDK) you want is under Configure -> SDK Configuration. This is where you should pick version 29.
You have to pair the SDK with an appropriate Native Development Kit (NDK). In this case, click “SDK Tools” in the SDK Configuration and then click “Show Package Details” to expand the selections. I installed version 21.3.
You may need Java’s SDK installed as well if you don’t already have it. I had OpenJDK 12 installed already, and that has worked well. I suspect anything version 8+ should work.
Tip 2: Build in Windows
Generally, I prefer to do my programming in Linux. There are many more tools natively available to the developer and you can “use the whole box” rather than the limitations Windows places on individual processes. That dramatically speeds up development.
I tried a couple different times to get this working in Linux, the Mint distro specifically, but it is a far lengthier path. Because Unreal doesn’t have their Engine built for “Linux” natively, they require you to build it from the code repository. That build alone took several hours, and each iteration I tried was taking hours more without any success because of the initial setup wait times of the Unreal Engine once it’s built. I’ll go back and try again later and update this guide if I get it working.
To get started quickly, use Windows 10. This allows you to use the “Binary Option” listed in the Oculus quick start guide I linked above.
In short, I was able to use the latest released version of Unreal Engine 4 through the Epic Games Launcher. Several online guides have suggested using older versions for various reasons, but with the Quest 2, those are all outdated. Get the latest.
Tip 3: Specify your build versions in Unreal Engine
Step 8 of the “Setup Unreal Engine for Android Development” section of the Oculus quick start guide specifies the use of Android SDK 23 as the minimum version and 25 as the targeted version. Again, with the Quest 2 running Android 10, I set both the minimum and targeted versions to Android 29.
Step 10 of the same section says that Unreal Engine will pick up the default locations of the Android SDK, Android NDK, and Java SDK. I found this doesn’t always work, but it’s easy to specify manually. Locate your installed Java SDK and use that version in your settings. Android Studio should install the Android SDK to your user’s AppData/Local/Android/Sdk folder, and the Android NDK to your user’s AppData/Local/Android/Sdk/ndk/<version number> folder.
Tip 4: Be patient, but prudent
Unreal Engine doesn’t seem to always report what it’s doing in the background. If you find you’re waiting forever, check your task manager. Expand tasks under Unreal Engine and you may find several threads started up. These may be building shaders or building the project itself. If they’re there while Unreal Engine is frozen, just wait.
And be patient. It can take hours to build shaders the first time, and it can take 30 minutes or more to rebuild the project or shaders if things go wrong.
Things definitely went wrong for me several times as I experimented with the platform! Sometimes this was a build issue where Unreal incorrectly detected duplicate resources or lost access to adb or other strange issues. If the build bombs out constantly even when everything else appears to be correct, you can delete the Intermediate and Saved folders in your project. This will cause Unreal to rebuild them, which will take a very long time again but is an easy way out of some of the strange conflicts that arise.
Another issue pops up when Unreal doesn’t clean up correctly when it closes. Sometimes it will leave Android Studio running (Unreal Engine is based on Android Studio), or adb.exe running (which communicates with your Android device), or various other OVR or Epic tasks. If those are running even though Unreal Engine itself is closed, you may not be able to start Unreal Engine again. You might have to kill those tasks manually from the Task Manager, and once you do that you should be able to start up the Engine again.
Tip 5: Don’t try to use Unreal Engine’s VR base project
Oculus suggests in their startup that you begin with a blank project, and they’re right. The VR project base simply doesn’t work. You’ll have to build up many of the niceties from scratch (or from other tutorials at least), but at least you’ll be able to build and deploy.
If you need some help getting started with Unreal Engine itself, I found the following tutorials were very well done:
Tip 6: Magic numbers get you “Roomscale”
There are many things you can do to make a great VR experience, but top among them is using the headset’s location to “automatically” adjust the user’s view. This helps both for better immersion and less nausea.
It wasn’t immediately obvious how to accomplish this, though, and the answer is a specific setup for your pawns:
- Create a new Blueprint pawn
- Under the Default Scene Root in that blueprint, add another scene and name it VRCameraRoot (for example)
- Under VRCameraRoot, add a camera and name it VRCamera (for example)
- Each of these should be scaled to 1 and set to 0,0,0 in their respective details windows
- Make sure "Lock to Hmd" is checked under Camera Options in the VRCamera
- Add a Set Tracking Origin in the pawn's event graph, make sure the Origin is "Floor Level" and have it called from Event BeginPlay
- When you place the pawn, make sure you place it at height "0" (or whatever floor height you're using)
This might look a little strange as the floor bisects your VR character’s camera, but it’s what the Quest 2 and Unreal Engine use as a clue to know it should adjust to the height of the Quest 2 (configured by the Quest 2 when you set your Oculus Guardian up).
Tip 7: Have fun
As always, have fun making cool new things! I’m new to Unreal Engine, so this whole “Blueprint” method of coding is pretty interesting. Nevertheless, I was up and running as quickly as shader compilation would allow after following the steps outlined above. Here are a few examples of what I was able to build:
First thing I built was a closet. Really! I am planning on converting an odd space in a bedroom into a larger closet, but it’s a strange size even for a closet. I set it up in VR so I could see how it felt walking into the space. I decided it’s actually a pretty useful size!
Photo by author
Second, I started playing with effects, backgrounds, and motion. I set up a space scene with orbiting “planets” that I could walk around in.
Photo by Author
I will probably keep developing this VR scene into a mini RTS game. I have a lot to learn in Unreal and in VR and having a project always helps! The Quest 2 is one of the most advanced VR headsets available today. While that will change rapidly, the base skills to create VR scenes will be useful for quite some time. Pick a project, and get going!
What it’s like to go glamping 1-hour from Washington, DC
Our experience glamping with Tentrr. A perfect weekend getaway during the lockdown!
How To: Build a Garden Planter Box
Build a sturdy planter box on a limited budget.
7 Smartphone Applications for travel and home safety
Download these today! Maps, first aid, secure texting, VPN, and more.
Unboxing My GPS Locator & Satellite Communication Beacon
The Garmin inReach Mini: Extreme Gear For Extreme Travellers!
Networking Your Home: Network Equipment
A series of articles on building and managing a home network
Save Money by Reducing Your Carbon Footprint
Doing good for the environment can be a win-win
9 Pieces of Advice Every Incoming College Student Needs to Know
Tips For New College Freshman to Maximize Their Experience
Finding Upside in an Uncertain Job Market
Advice for job seekers on moving forward in difficult times