Using the Unreal VR Template Project
This guide will demonstrate how to use the UE Enhanced Inputs to modify the Unreal Engine VR Template VRPawn blueprint graph to work with the Magic Leap 2 controller.
Prerequisites
Enable the Magic Leap Controller
- Go to Edit > Plugins > enable the Magic Leap OpenXR and Magic Leap Controller plugins. If prompted to restart the editor, click Restart.
Import the VR Template
- Import the UE VR Template contents into your project by going to the Content Browswer and clicking Add > Add Feature or Content Pack > Virtual Reality > Add to Project
Edit the IMC_Default Input Mapping Context
- Go to Content > VRTemplate > Input and open the IMC_Default input mapping context
- For each Input Action in the list, remove all non-Magic Leap controller inputs and replace them with the desired input button from the Magic Leap Controller using the dropdown > Magic Leap Controller. Use the screenshot below as a reference.
- Save and close the IMC_Default asset after completing these steps
Edit the VRPawn
- In the Content Brower, select Content > VRTemplate > Blueprints > VRPawn
- In the hierarchy, select Add > Magic Leap Controller
- With the Magic Leap Controller selected in the hierarchy, click Add > XRDeviceVisualization
- Select the XRDeviceVisualization and in the Details window under Visualization > enable Is Visualization Active and change the Display Model Source to OpenXR
- Select the Magic Leap Controller in the Components hierarchy and in the Details panel, find Motion Controller > Motion Source. Change the Motion Source to AnyHand.
- Find the Input Action Grab Left portion of the blueprint.
- Add the Magic Leap Controller Variable (Get) node to the blueprint and plug it into the Motion Controller input pin of the Get Grab Component Near Motion Controller and Try Grab nodes in this graph. Use the screenshot below for reference.
Repeat the same steps for the Input Action Grab Right graph.
Compile the Blueprint and Save the project.
Configure Project Settings and Package the Project
In the Unreal Editor main menu, select Edit > Project Settings.
In the project settings window, go to Maps & Modes. Under Default GameMode, change the settings to VRGameMode. Under Default Maps, set Editor Startup Map and Game Default Map to the VRTemplateMap.
In the Unreal Editor main menu, select Edit > Project Settings. In the Project - Description list, go to Settings. Select Start in VR.
Under Project Settings, go to Platforms and select Android. Under Android, go to APK Packaging. Click the Configure Now button in the red box.
The red box turns green.
Under APK Packaging, select Package game data inside .apk.
Under Android, go to Build. Under Build, set these options:
- Deselect Support arm64 [aka arm64-v8a].
- Select Support x86_64 [aka x64].
- Deselect OpenGL ES3.2.
- Select Support Vulkan.
Under Android, go to Launch Images. Under Launch Images, deselect Show launch image.
Under Android, go to Multi Texture Formats. Under Multi Texture Formats, set these options:
- Deselect Include ETC2 textures.
- Select Include DXT textures.
- Deselect Include ASTC textures.
Close the project setting window.
Build the package
In the Unreal Editor main toolbar, select Platforms > Android. Select Android (DXT).
Select Package Project.
In the dialog window that appears, choose where to store your built files and save.
Deploy the app
After your app is built, you can deploy it using the .bat
file saved to your build location. You can also install the .apk file from your build location using Magic Leap Hub.
Upon completing these steps, you will be able to grab objects, teleport, and access the menu in the VRTemplate Scene.