Unreal and Hololens 2 – Step 5 Set Up for Mixed Reality

Again I am following the Microsoft tutorial, just adding in extra screen grabs to help solidify the process in my mind. For the original tutorial, look here https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unreal/tutorials/unreal-uxt-ch3

 

Add The Session Asset

To use a session, you need an ARSessionConfig data asset to work with. To create one of these go to your Content Browser window. Make sure you are in the root Content folder by clicking on the Content folder.

Click Add/Import > Miscellaneous > Data Asset 

 

Select ARSessionConfig, click Select

 

 

name the asset ARSessionConfig.

 

 

Double-click ARSessionConfig to open it, leave all default settings and hit Save. Return to the Main window.

 

 

Start and Stop AR Session

 

To start the AR session you use a Level Blueprint. Connecting the ARSessionConfig asset in the Level Blueprint guarantees the AR session will fire right when the game starts playing.

To do this click Blueprints > Open Level Blueprint from the editor toolbar:

 

 

This will open up the Eventgraph window. Now this is node based work, so if you’ve ever used Shadergraph or Houdini then you’ll be familiar with this kind of coding. If not then just hang in there, this is a really easy entry example to set up. Don’t worry, you’ll get used to it.

Drag the execution node (left-facing arrow icon) off Event BeginPlay and release

 

 

then search for the Start AR Session node

 

 

and hit enter. Excellent, you just connected two nodes.

 

 

Click the Select Asset dropdown under Session Config and choose the ARSessionConfig asset.

 

 

Right-click anywhere in the EventGraph and create a new Event EndPlay node. 

 

 

Just like we did for the BeginPlay Event, we’re going to drag the execution pin and release, then search for a Stop AR Session node and hit enter.

 

Hit Compile, then Save and return to the Main window.

 

 

create a pawn

At this point, the project still needs a player object. In Unreal, a Pawn represents the user in the game, but in this case it’s going to be the HoloLens 2 experience.

 

Click Add New > Blueprint Class in the Content folder

 

 

Expand the All Classes section at the bottom. Search for DefaultPawn, click Select

 

 

Name it MRPawn, and double-click the asset to open.

 

 

Click Add Component > Camera from the Components panel and name it Camera.

 

 

Make sure that the Camera component is a direct child of the root (CollisionComponent). This allows the player camera to move with the HoloLens 2 device.

 

 

Select CollisionComponent from the Components panel and scroll down to the Collision section of the Details panel.

  • Click the Collision Presets dropdown and change the value to NoCollision.
  • Do the same for the MeshComponent

 

 

Compile and Save the Blueprint, then return to the Main Window

 

 

create a game mode

 

The last puzzle piece of the mixed reality setup is the Game Mode. The Game Mode determines a number of settings for the game or experience, including the default pawn to use.

 

Click Add New > Blueprint Class in the Content folder and select Game Mode Base as the parent class. 

 

 

Name it MRGameMode and double-click to open.

 

 

Go to the Classes section in the Details panel and change the Default Pawn Class to MRPawn

 

 

Hit Compile, then Save and return to the Main window.

 

 

Select Edit > Projects Settings and click Maps & Modes in the left-hand list.

  • Expand Default Modes and change Default Game Mode to MRGameMode.
  • Expand Default Maps and change both EditorStartupMap and GameDefaultMap to Main. When you close and reopen the editor or play the game, the Main map will now be selected by default.

 

<<<< STEP 4 – CREATE A LEVEL        STEP 6 – INTERACTIVity >>>>