Skip to main content
Version: 12 Dec 2024

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
Add VR Template to project

Edit the IMC_Default Input Mapping Context

  1. Go to Content > VRTemplate > Input and open the IMC_Default input mapping context
  2. 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.
IMC_Default settings
  1. Save and close the IMC_Default asset after completing these steps

Edit the VRPawn

  1. In the Content Brower, select Content > VRTemplate > Blueprints > VRPawn
  2. In the hierarchy, select Add > Magic Leap Controller
  3. With the Magic Leap Controller selected in the hierarchy, click Add > XRDeviceVisualization
Select Package Project
  1. Select the XRDeviceVisualization and in the Details window under Visualization > enable Is Visualization Active and change the Display Model Source to OpenXR
Select Package Project
  1. 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.
Select Package Project
  1. Find the Input Action Grab Left portion of the blueprint.
  2. 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.
Input Grab Left graph
  1. Repeat the same steps for the Input Action Grab Right graph.

  2. Compile the Blueprint and Save the project.

Configure Project Settings and Package the Project

  1. In the Unreal Editor main menu, select Edit > Project Settings.

  2. 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.

  3. In the Unreal Editor main menu, select Edit > Project Settings. In the Project - Description list, go to Settings. Select Start in VR.

    Enable Start VR in Project Settings
  4. Under Project Settings, go to Platforms and select Android. Under Android, go to APK Packaging. Click the Configure Now button in the red box.

    Configure your project for the Android platform in Project Settings

    The red box turns green.

  5. Under APK Packaging, select Package game data inside .apk.

    Set .apk packaging in Project Settings
  6. 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.
    Set build options in Project Settings
  7. Under Android, go to Launch Images. Under Launch Images, deselect Show launch image.

    Disable showing launch image in Project Settings
  8. 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.
    Set multi-texture formats in Project Settings
  9. Close the project setting window.

Build the package

  1. In the Unreal Editor main toolbar, select Platforms > Android. Select Android (DXT).

    Set the build platform to Android (DXT)
  2. Select Package Project.

    Select Package Project
  3. 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.