VR/AR Setup

Important Notice

1: Check that your PC is able to run VR before starting the process of integrating it into Unity/ Unreal Engine. More Info about specs needed here: More Info

2: We used Windows 10 (Version 1909) with Samsung Galaxy Note 10 and Huawei P20 (Android Version 10) for setting up these instruction and therefore there might be different behaviors based on what phone and version of windows you are using on the PC.

3. The instructions were last tested in Unity version 2019.4.2f1, later versions might get errors that have not been found during the testing sessions. Also earlier versions might not have all the menus and buttons that have been shown throughout the guides.

Unity

Oculus Rift (Unity)

  1. Install the Oculus App on your PC from: Oculus Setup: Rift S, Rift, Quest & Go
  2. Log in with your Facebook/ Oculus account or register at: Create an Account
  3. Choose which Oculus you got, this is for the application to get the correct drives.
  4. Connect the USB cables from the sensors to any USB port on the computer.
    1. It is best not to use dongles as the data might get corrupted in transferring to computer from the sensor.
  5. Connect the headset to any USB port on the PC and connect the HDMI.
    1. Use the fastest USB port you have on the PC for the best transfer speed.
    2. You may meet a problem with your HDMI connection in the Oculus application. In some cases either Resetting the application or restarting the computer can fix it.
  6. Choose which controllers you want to use in the Oculus application
  7. Pairing the controllers
    1. The application will show instructions on the screen on how to pair the controllers depending on which on it is.
  8. After this, the sensors will perform a communication check to prepare for tracking the headset.
  9. Go to settings in the Oculus App and then choose the Beta tab. Enable public test channel, this is to make the USB connection more stable.
  10.  Wait for the software updater to be finished.
  11. In Oculus App, go to Settings > General Tab and activate Unknown Sources to be able to use the headset with other software than the Oculus App.
  12. Make a new Unity project. Make sure it is 3D.
  13. In Unity, go to Edit > Project Settings. A new window will then appear. If you have not installed the XR plugin yet a button labeled Install XR Plugin Management. Click it. When it is installed click on XR Plug-In Managment on the left side of the new window and activate the tick box that says Oculus.

How to add a player

  1. Go to Window/Asset Store and search for the Oculus Integration asset. Download the asset
  2. When download is complete, a blue button with import will appear. Import everything into the project. There might appear some small windows after you have importet the asset. Make sure to click the already highlighted buttons.
  3. Once this is done, you can close the asset store window, if you have not plugged in the Oculus Rift before, you can do so now.
  4. When you put the headset on your head. Confirm the ground height and the play space that you have available with your right controller and press confirm.
  5. Go back into Unity and remove the current MainCamera in the Hierarchy. Go down to the Project panel and search for OVRPlayerController. Then put the OVRPlayerController prefab in the hierarchy instead.(This was downloaded in the Oculus Asset Package).
  6. Test that everything is working correctly by pressing Play in Unity and see if the camera responds to the movement of the Oculus Rift.
  7. You can also check that the joysticks are working by using the thumb sticks, while the thumb sticks on the left controller will move you forward in the direction you look towards.

How to show controllers in Unity

  1. Click on the OVRPlayerController (Hierarchy) and click on add component in the Inspector that is on the right side and search for CharacterCameraConstraint and add it.
  2. On the CameraCharacterConstraint in the CameraRigTab, click the circle on the right side of the box and add OVRCameraRig from the new tab that appears.
    1. If it does not appear in the menu that pops up, go to the project tab and search for CameraRig and it should appear.
  3. Go to the Project panel and search for the LocalAvatar prefab and drag it into TrackingSpace in the hierarchy under OVRPlayerController prefab.

 

Making hands able to interact

  1. Find LefthandAnchor and RightHandAnchor under the OVRPlayerController in the hierarchy.
    1. Select them both and add a sphere collider.
    2. Set to radius 0.5
    3. Check IsTriggerBox
    4. Add OVRGrabber script to both.
    5. Check ParentHeldObject or you will see some jumpiness when holding and object and moving your hands.
    6. Expand the RightHandAnchor and the Right ControllerAnchor under it.
      1. On the RightHandAnchor, drag and drop the RightHandControllerAnchor to the GripTransformField
      2. Under GrabVolumes on the RightHandAnchor set the size to 1.
      3. Drag the sphere collider of the RightHandAnchor into the field that will appear beneath.
      4. In the controller dropdown menu, select R Touch.
    7. Expand the LeftHandAnchor and the Left ControllerAnchor under it.
      1. On the LeftHandAnchor, drag and drop the LeftHandControllerAnchor to the GripTransformField
      2. Under GrabVolumes on the LeftHandAnchor set the size to 1.
      3. Drag the sphere collider of the LeftHandAnchor into the field that will appear beneath.
      4. In the controller dropdown menu, select L Touch.

If hands do not show

  1. If the hands do not show after the process, it might have to do with the ID being 0. This can be fixed with changing the ID.
    1. Oculus > Avatars Edit Settings  from the tab menu at the top menu in Unity.
    2. Change both of these numbers to something you want.
    3. It also has to be changed on the LocalAvatar (Oculus User ID)

 

 

Oculus Quest (Unity)

  1. Install the Oculus App on your PC from: Oculus Setup: Rift S, Rift, Quest & Go.
  2. Log in with you Facebook/ Oculus account or register at: Create an Account.
  3. Choose which Oculus you got, for the application to get the correct drivers.
  4. Connect the cables from the sensors to any of the USB Ports on the PC. (3.1 also works).
  5. Turn on the Oculus Quest with the button on the right side on front.
  6. When wearing the headset, you need to confirm the Guardian of the Oculus. This is done with the right controller by pressing the button on the back of the controller.
  7. Go to setting in the Oculus app and then choose the Beta Tab, Enable public. Enable public test channel. This is to make the USB connection more stable.
  8. Wait for the software updater to be finished.
  9. Go to Settings > Headset Tab > Enable Oculus Link(Beta) in the menu in the Oculus headset. After this has been done, the beta functionality for the Oculus will be active.
  10. In the Oculus App, go to Settings > General Tab > Activate Unknown Sources to be able to use the headset with other software than the Oculus App. Like for example Unity and Unreal Engine.
  11. In Unity, go to Edit > Project Settings. A new window will then appear. Click on XR Plug-In Management on the left side of the new window and activate the tick box that says Oculus.
  12. Go to Project Settings > XR Plug-In Management and expand it. Click on the Oculus tab and tick the Oculus Box.

    How to add a player

    1. Go to Window/Asset Store and search for the Oculus Integration asset. Download the asset
    2. When download is complete, a blue button with import will appear. Import everything into the project. There might appear some small windows after you have importet the asset. Make sure to click the already highlighted buttons.
    3. Once this is done, you can close the asset store window, if you have not plugged in the Oculus Quest before, you can do so now.
    4. When you put the headset on your head. Confirm the ground height and the play space that you have available with your right controller and press confirm.
    5. Go back into Unity and remove the current MainCamera in the Hierarchy. Go down to the Project panel and search for OVRPlayerController. Then put the OVRPlayerController prefab in the hierarchy instead.(This was downloaded in the Oculus Asset Package).
    6. Test that everything is working correctly by pressing Play in Unity and see if the camera responds to the movement of the Oculus Quest.
    7. You can also check that the joysticks are working by using the thumb sticks, while the thumb sticks on the left controller will move you forward in the direction you look towards.

    How to show controllers in Unity

    1. Click on the OVRPlayerController (Hierarchy) and click on add component in the Inspector that is on the right side and search for CharacterCameraConstraint and add it.
    2. On the CameraCharacterConstraint in the CameraRigTab, click the circle on the right side of the box and add OVRCameraRig from the new tab that appears.
      1. If it does not appear in the menu that pops up, go to the project tab and search for CameraRig and it should appear.
    3. Go to the Project panel and search for the LocalAvatar prefab and drag it into TrackingSpace in the hierarchy under OVRPlayerController prefab.

     

    Making hands able to interact

    1. Find LefthandAnchor and RightHandAnchor under the OVRPlayerController in the hierarchy.
      1. Select them both and add a sphere collider.
      2. Set to radius 0.5
      3. Check IsTriggerBox
      4. Add OVRGrabber script to both.
      5. Check ParentHeldObject or you will see some jumpiness when holding and object and moving your hands.
      6. Expand the RightHandAnchor and the Right ControllerAnchor under it.
        1. On the RightHandAnchor, drag and drop the RightHandControllerAnchor to the GripTransformField
        2. Under GrabVolumes on the RightHandAnchor set the size to 1.
        3. Drag the sphere collider of the RightHandAnchor into the field that will appear beneath.
        4. In the controller dropdown menu, select R Touch.
      7. Expand the LeftHandAnchor and the Left ControllerAnchor under it.
        1. On the LeftHandAnchor, drag and drop the LeftHandControllerAnchor to the GripTransformField
        2. Under GrabVolumes on the LeftHandAnchor set the size to 1.
        3. Drag the sphere collider of the LeftHandAnchor into the field that will appear beneath.
        4. In the controller dropdown menu, select L Touch.

    If hands do not show

    1. If the hands do not show after the process, it might have to do with the ID being 0. This can be fixed with changing the ID.
      1. Oculus > Avatars Edit Settings  from the tab menu at the top menu in Unity.
      2. Change both of these numbers to something you want.
      3. It also has to be changed on the LocalAvatar (Oculus User ID)

     

     

Vive (Unity)

  1. Install the Vive App on your PC from: Get Started with VIVE
  2. Log in with either Steam/ Google/ Facebook Account
    1. If no account, register at: Welcome to HTC Account
  3. Get a room that is big enough:
    1. Minimum 2mx1.5m
  4. Pick a spot for the play area
    1. Pick a spot for the sensors(Bases) and set them opposite of each other. (They will each need a power outlet)
    2. You will have to use the controllers that come with the headset or else they will not properly connect. You also have to be in SteamVR on the PC for the headset to turn on.
    3. The sensors should be above head level (Over 2m)
    4. Angled towards towards the play area at an angle of 30 - 45 degrees.
    5. Have unobstructed view of each others.
  5. Adjust the sensors
    1. If old one:
      1. Press mode on the buttons on the rear of the sensors and make sure that one is lit up with a B and the other with C. The light will be showing at the front of the camera.
    2. If it's the new one, they should up automatically and be assigned letters.
  6. Connect the link box (The side that does NOT have orange ports)
    1. Use the HDMI cable to connect the link box to your computer
    2. Plug in a power cord and plug it into a power outlet
    3. Once it's connected to your computer, it should automatically start downloading and installing the drivers needed.
  7. Install headset
    1. The end of the headset has 3 in 1 tether of tree orange tipped cords. (USB, HDMI and Power). Plug in all these to the link box on the side WITH orange ports.
    2. After this, the computer will start automatically install drivers for the headset itself.

Integrating VIVE with Unity

  1. Open a project create a new and go to Window > Asset Store and import SteamVR Plugin.
    1. Import all when you get prompted for what to import into the project.
    2. Some versions of Unity might require and API update, press I Made a Backup. Go Ahead!
    3. You will get a window for optimizing the VR settings, accept all for it to automatically set the best settings.
    4. Open the SteamVR > InteractionSystem > Core > Prefabs and select [Player] prefab and drag them to the hierarchy in the current scene.
    5. Delete the MainCamera, as this one will not be used in the project when using VR.

Binding buttons to actions in Unity

  1. When pressing play in Unity, there will come a pop up to ask you to generate the JSON files for the controllers which contains the info about all the actions that the buttons do.
  2. Press Save and Generate when SteamVR Input window comes up, then close the window down.
  3. Activate teleporting:
    1. Find the teleporting prefab which is located in the SteamVR > InteractionSystem > Teleport > Prefabs folder and drag it into the hierarchy of the scene you are working in.
    2. Add a plane by  Right Clicking > 3D Object > Plane in the Hierarchy.
    3. Click on the plane and press on the right side in the inspector  and Add Component. Add the TeleportArea. Write that in the search bar that comes up and it should show up.
    4. You need to take care that the Player and Teleporting prefab in the Hierarchy is at least 0.5 over another GameObject or else the teleportation function will not work.
    5. The player also has to be above the teleportation plane, or else it will not work.

Unreal Engine 4

Oculus Rift (Unreal Engine 4)

  1. Install the Oculus App on your PC from: Oculus Setup: Rift S, Rift, Quest & Go
  2. Log in with your Facebook/ Oculus account or register at: Create an Account
  3. Choose which Oculus you got, this is for the application to get the correct drives.
  4. Connect the USB cables from the sensors to any USB port on the computer.
    1. It is best not to use dongles as the data might get corrupted in transferring to computer from the sensor.
  5. Connect the headset to any USB port on the PC and connect the HDMI.
    1. Use the fastest USB port you have on the PC for the best transfer speed.
    2. You may meet a problem with your HDMI connection in the Oculus application. In some cases either Resetting the application or restarting the computer can fix it.
  6. Choose which controllers you want to use in the Oculus application
  7. Pairing the controllers
    1. The application will show instructions on the screen on how to pair the controllers depending on which on it is.
  8. After this, the sensors will perform a communication check to prepare for tracking the headset.
  9. Go to settings in the Oculus App and then choose the Beta tab. Enable public test channel, this is to make the USB connection more stable.
  10.  Wait for the software updater to be finished.
  11. Go to Settings > Headset Tab > Enable Oculus Link (Beta) in the menu in the Oculus headset.
  12. In Oculus App, got to Settings > General Tab and activate unknown sources to be able to use the headset with other software than the Oculus App.

Setting up Unreal Engine 4 for VR

  1. Open up Unreal Engine and select the Games tab under the New Project Categories header then click next.
  2. Select the Blank from the Select Template and click next.
  3. Make sure you use Blueprint and choose the target platform as Desktop/ Console. You can choose if you want the starter content. For this example i will not be using the starter content. Choose a place to save your project and what to call you project. The press Create project.
  4. When everything has loaded. Delete the Player Start actor in the World Outline.
  5. Inside the Content Browser right click on Content folder. You will then get a drop down menu, Click the Blueprint Class tab.
  6. Inside the pick parent class, click the character button.
  7. This will be your player character in the game. I called my character PlayerCharacter. Make sure you name it something you will remember.
  8. Right click inside the Content folder inside the Content Browser again. Choose the Blueprint Class and now click the Game Mode Base. Name it something you will remember. I named it VRGameMode.
  9. Drag you Character into the Level. You should now be able to put on your VR headset and look around in the Level. You will notice that you are at the same position as your Character. That is fine, it will be fixed later.
  10. Double click the Game Mode Base(I named it VRGameMode) and  a new window will open Inside it. Under Classes, find the Default Pawn Class. Open the drop down menu and select you Character as the Default Pawn Class. The press Compile and Save buttons in that order. You will know it has compiled once the button has changed from question mark to check mark.
  11. After this, we need to make sure that the Game Mode Base we made is the one in use. Click on Settings and World Settings. On the right side of the screen a menu will come.
  12. In the World Settings find Game Mode and change the GameMode Override to your Game Mode Base.
  13. In the World Outline select your Character. In Details make sure you have the Character selected and not any of the children. Scroll down until you find Pawn. Change the Auto Possess Player from Disabled to Player 0. If you play now, you will start where your Character is located.
    1. Click on the drop down button beside the play button. Select VR Preview in the drop down menu.
  14. The next thing will be to add movement to your Character. We will make a Locomotion controller. Firstly, under the Settings tab, click the Project Settings… A new window will open.
  15. In Project Settings, go to the left of the screen scroll down until you find Engine and under Engine, find the Input tab.
  16. Now we must apply some inputs for the touch controllers for the VR headset. We will be able to move forwards, backwards, right and left with the joystick for the left touch controller. We will be able to rotate both right and left with the right touch controller. We will also be able to hold down a button to pick up some objects.
  17. To be able to move, go to Bindings and press the plus icon beside Axis Mapping. Expand Axis Mappings and name the Axis Mapping. I will call it Move_Forward_Backword. Expand the Axis Mapping and press the Select the key value. Find Oculus Touch, expand it and select Oculus Touch(L) Thumbstick Up. Press the plus icon beside the Axis Mapping and add the Oculus Touch(L) Thumbstick Down. Beside the Oculus Touch(L) Thumbstick Down set the Scale to -1. Do the same for the right and left input so it looks like this.
  18. Close Project Settings. We will now make the inputs we defined work with the Character. Double click your Character to open it. You should have a window looking like this.
  19. First, delete all the nodes in the middle window. To create a node, you right click inside the window and search for the node you want. We want the inputs we made, so I search for Move_Forward_Backward. Make sure to select from Inputs and Axis Events. The node you get should be red. The next node is the Add Movement Input. The last node is Get Actor Forward Vector. After you have added all the nodes, connect them like this.
  20. You can now press Compile and Save. If you play the game now you should be able to move towards where you are looking and backwards in the opposite direction.
  21. You can now do the same for the movement to right and left. Like it is done in the picture below. You should now be able to move left and right as well.
  22. Now we will make it possible to rotate with the right Touch Controller. Go to Input in Project Settings. Add a new Axis Mapping and bind Oculus Touch (R) Thumbstick Right and Left. And set Oculus Touch (R) Thumbstick Left value to -1.
  23. Inside your Character add your rotation input as well as an Add Controller Yaw Input. Connect them like this. Compile and save. You should now be able to rotate with your right Touch controller.
  24. Now it’s time to add the Touch controllers and make you able to grab some items with them.
  25. To add the controllers, you need to open your Character. Inside Components press Add Component and search for Motion Controller. Add one for each and call them something you will remember. I called them Right_Hand and Left_Hand.
  26. Select one of the Motion Controller components and go to the right of the screen to Details. Find Visualization and enable Display Device Model. In the Display Model Source, choose OculusHMD. Then find Motion Controller under Visualization. Make sure that Motion Source is set to the correct hand. Do the same for the other Motion Controller.
  27. Select one of the Motion Controller components. Press Add Component and search for Box Collision and add it. I named the Box Collisions for Box_Right and Box_Left. Set the scale of the Box Collision to 0.15 in Details and Transform. Do the same for the other Motion Controller. Press Compile and Save. You should now be able to see your controllers when playing.
  28. The first thing you need to do is to make an Interface. The interface will be a way to determine if the object you are touching can be picked up. Right click inside the Content Browser and hover over Blueprints and click Blueprint Interface. Call it something you will remember. I called mine Interactible.
  29. Go to Components in your Character and Add Component. Search for Camera and click it.
  30. Open the Interface. On the right side inside My Blueprint make two functions. One grabbing up the object and one for dropping the object. I called mine Grab and Drop. When we grab the object, it should know what is grabbing it. Select the Grab function, inside Details press the plus icon beside Inputs. A new parameter will appear, call it something you will remember. I called it AttachTo. Change from a bool Parameter to a Scene Component as an Object Reference. The press Compile and Save.
  31. We will now make the hands be able to pick things up. I’m starting with the right hand. The first thing you need to do is to add some button inputs to check if you are grabbing. Go to Project Settings and Input. Press the plus icon beside Action Mapping. Add two actions. One for the right hand grab and one for the left. Call them something you remember. I called them Grab_Right and Grab_Left. For the Grab_Right add Oculus Touch (R) Grip, and Oculus Touch (L) Grip for Grab_Left.
  32. We will now use the Event Graph in your Character to connect what we have done, so you will be able to pick things up.
    1. Right click, search for Grab_Right and add the InputAction Grab_Right. Then, right click and search for Grab and add Grab(Message). Right click and search for Drop and add Drop(Message).
    2. Search and add Get Overlapping Actors (Box_Right). Now, drag the Motion Controller component for the right hand (Right_Hand) into the Event Graph.
    3. Search and add Get (a copy), and lastly connect the Nodes as done here.
  33. Do the same for the left Motion Controller component. Then Compile and Save.
  34. Now it is time to add the objects you can pick up. From Place Actors drag Cube into the level. Call it something you remember in the World Outliner and make sure it is Movable in Details under Transform. You can also scale it down like I have done under Transform. I scaled it to 0.25.
  35. In Details, click the Blueprint/Add Script button. Give it a name and press Select
  36. After the new blueprint has opened, go to Event Graph. Delete the existing Nodes, but before adding new nodes we need a reference to the interface we made earlier. Click Class Settings, in Details find Interfaces and add the interface we made. Press Compile and Save.
  37. Right click inside the Event Graph, search and add Event Grab. Then add a Set Simulated Physics node. This node should generate a Static Mesh Component. Keep this node and add it if you do not get it. Search and add an AttachComonentToComponent node, as well as a Root Component node. Then connect them like this. 
  38. We have now made it possible to grab this object, but not to drop it. Search and add Event Drop, as well as a Set Simulated Physics node with the Static Mesh Component node. The last node will be DetachFromActor. Connect them like this.
  39. There is one more thing we need to do before we can pick up this object. That is to give it a collider in order to check if the controllers and the object are overlapping. Go to Components press Add Component and add a Box Collision. Select the Collision component, go to Details and under Collision, set Collision Presets to OverlapAll. Compile and Save and now you should be able to pick up the object.

 

 

 

 

Oculus Quest (Unreal Engine 4)

  1. Install the Oculus App on your PC from: Oculus Setup: Rift S, Rift, Quest & Go.
  2. Log in with you Facebook/ Oculus account or register at: Create an Account.
  3. Choose which Oculus you got, for the application to get the correct drivers.
  4. Connect the cable from the headset (Front left side) to any of the USB Ports on the PC. (USB Port type 3.1 also works. 3.0 or higher is preferred).
  5. Turn on the Oculus Quest with the button on the right side on the front.
    1. You might get a question in the Oculus to allow Data Access from the PC. This needs to be allowed.
  6. When wearing the headset, you need to confirm the Guardian of the Oculus. This is done with the right controller by pressing the button on the back of the controller.
    1. if you ever move out of bounds from the current guardian(Play Area) that you have currently set up. You will be asked to set up a new one.
  7. Go to setting in the Oculus app and then choose the Beta Tab, Enable public. Enable public test channel. This is to make the USB connection more stable.
    1. If update is necessary, wait until finished before continuing.
  8. Go to Settings > Headset Tab > Enable Oculus Link(Beta) in the menu in the Oculus headset. After this has been done, the beta functionality for the Oculus will be active.
  9. In the Oculus App, go to Settings > General Tab > Activate Unknown Sources to be able to use the headset with other software than the Oculus App. Like for example Unity and Unreal Engine.

Setting up Unreal Engine 4 for VR

  1. Open up Unreal Engine and select the Games tab under the New Project Categories header then click next.
  2. Select the Blank from the Select Template and click next.
  3. Make sure you use Blueprint and choose the target platform as Desktop/ Console. You can choose if you want the starter content. For this example i will not be using the starter content. Choose a place to save your project and what to call you project. The press Create project.
  4. When everything has loaded. Delete the Player Start actor in the World Outline.
  5. Inside the Content Browser right click on Content folder. You will then get a drop down menu, Click the Blueprint Class tab.
  6. Inside the pick parent class, click the character button.
  7. This will be your player character in the game. I called my character PlayerCharacter. Make sure you name it something you will remember.
  8. Right click inside the Content folder inside the Content Browser again. Choose the Blueprint Class and now click the Game Mode Base. name it something you will remember. I named it VRGameMode.
  9. Drag you Character into the Level. You should now be able to put on your VR headset and look around in the Level. You will notice that you are at the same position as your Character. That is fine, it will be fixed later.
  10. Double click the Game Mode Base and  a new window will open Inside it. Under Classes, find the Default Pawn Class. Open the drop down menu and select you Character as the Default Pawn Class. The press Compile and Save buttons in that order. You will know it has compiled once the button has changed from question mark to check mark.
  11. After this, we need to make sure that the Game Mode Base we made is the one in use. Click on Settings and World Settings. On the right side of the screen a menu will come.
  12. In the World Settings find Game Mode and change the GameMode Override to your Game Mode Base.
  13. In the World Outline select your Character. In Details make sure you have the Character selected and not any of the children. Scroll down until you find Pawn. Change the Auto Possess Player from Disabled to Player 0. If you play now, you will start where your Character is located.
    1. Click on the drop down button beside the play button. Select VR Preview in the drop down menu.
  14. The next thing will be to add movement to your Character. We will make a Locomotion controller. Firstly, under the Settings tab, click the Project Settings… A new window will open.
  15. In Project Settings, go to the left of the screen scroll down until you find Engine and under Engine, find the Input tab.
  16. Now we must apply some inputs for the touch controllers for the VR headset. We will be able to move forwards, backwards, right and left with the joystick for the left touch controller. We will be able to rotate both right and left with the right touch controller. We will also be able to hold down a button to pick up some objects.
  17. To be able to move, go to Bindings and press the plus icon beside Axis Mapping. Expand Axis Mappings and name the Axis Mapping. I will call it Move_Forward_Backword. Expand the Axis Mapping and press the Select the key value. Find Oculus Touch, expand it and select Oculus Touch(L) Thumbstick Up. Press the plus icon beside the Axis Mapping and add the Oculus Touch(L) Thumbstick Down. Beside the Oculus Touch(L) Thumbstick Down set the Scale to -1. Do the same for the right and left input so it looks like this.
  18. Close Project Settings. We will now make the inputs we defined work with the Character. Double click your Character to open it. You should have a window looking like this.
  19. First, delete all the nodes in the middle window. To create a node, you right click inside the window and search for the node you want. We want the inputs we made, so I search for Move_Forward_Backword. Make sure to select from Inputs and Axis Events. The node you get should be red. The next node is the Add Movement Input. The last node is Get Actor Forward Vector. After you have added all the nodes, connect them like this.
  20. You can now press Compile and Save. If you play the game now you should be able to move towards where you are looking and backwards in the opposite direction.
  21. You can now do the same for the movement to right and left. Like it is done in the picture below. You should now be able to move left and right as well.
  22. Now we will make it possible to rotate with the right Touch Controller. Go to Input in Project Settings. Add a new Axis Mapping and bind Oculus Touch (R) Thumbstick Right and Left. And set Oculus Touch (R) Thumbstick Left value to -1.
  23. Inside your Character add your rotation input as well as an Add Controller Yaw Input. Connect them like this. Compile and save. You should now be able to rotate with your right Touch controller.
  24. Now it’s time to add the Touch controllers and make you able to grab some items with them.
  25. To add the controllers, you need to open your Character. Inside Components press Add Component and search for Motion Controller. Add one for each and call them something you will remember. I called them Right_Hand and Left_Hand.
  26. Select one of the Motion Controller components and go to the right of the screen to Details. Find Visualization and enable Display Device Model. In the Display Model Source, choose OculusHMD. Then find Motion Controller under Visualization. Make sure that Motion Source is set to the correct hand. Do the same for the other Motion Controller.
  27. Select one of the Motion Controller components. Press Add Component and search for Box Collision and add it. I named the Box Collisions for Box_Right and Box_Left. Set the scale of the Box Collision to 0.15 in Details and Transform. Do the same for the other Motion Controller. Press Compile and Save. You should now be able to see your controllers when playing.
  28. The first thing you need to do is to make an Interface. The interface will be a way to determine if the object you are touching can be picked up. Right click inside the Content Browser and hover over Blueprints and click Blueprint Interface. Call it something you will remember. I called mine Interactible.
  29. Go to Components in your Character and Add Component. Search for Camera and click it.
  30. Open the Interface. On the right side inside My Blueprint make two functions. One grabbing up the object and one for dropping the object. I called mine Grab and Drop. When we grab the object, it should know what is grabbing it. Select the Grab function, inside Details press the plus icon beside Inputs. A new parameter will appear, call it something you will remember. I called it AttachTo. Change from a bool Parameter to a Scene Component as an Object Reference. The press Compile and Save.
  31. We will now make the hands be able to pick things up. I’m starting with the right hand. The first thing you need to do is to add some button inputs to check if you are grabbing.Go to Project Settings and Input. Press the plus icon beside Action Mapping. Add two actions. One for the right hand grab and one for the left. Call them something you remember. I called them Grab_Right and Grab_Left. For the Grab_Right add Oculus Touch (R) Grip, and Oculus Touch (L) Grip for Grab_Left.
  32. In your Character, right click, search for Grab_Right and add the InputAction Grab_Right. Then, right click and search for Grab and add Grab(Message).
  33. Right click and search for Drop and add Drop(Message). Search and add Get Overlapping Actors (Box_Right).
  34. Drag the Motion Controller component for the right hand into the field as well as it’s Box Collider. Search and add Get (a copy), and lastly connect the Nodes as done here.
  35. Do the same for the left Motion Controller component. Then Compile and Save.
  36. Now it is time to add the objects you can pick up. From Place Actors drag Cube into the level. Call it something you remember in the World Outliner and make sure it is Movable in Details under Transform. You can also scale it down like I have done under Transform. I scaled it to 0.25.
  37. In Details, click the Blueprint/Add Script button. Give it a name and press Select
  38. After the new blueprint has opened, go to Event Graph. Delete the existing Nodes, but before adding new nodes we need a reference to the interface we made earlier. Click Class Settings, in Details find Interfaces and add the interface we made. Press Compile and Save.
  39. Right click inside the Event Graph, search and add Event Grab. Then add a Set Simulated Physics node. This node should generate a Static Mesh Component. Keep this node and add it if you do not get it. Search and add an AttachComonentToComponent node, as well as a Root Component node. Then connect them like this. 
  40. We have now made it possible to grab this object, but not to drop it. Search and add Event Drop, as well as a Set Simulated Physics node with the Static Mesh Component node. The last node will be DetachFromActor. Connect them like this.
  41. There is one more thing we need to do before we can pick up this object. That is to give it a collider in order to check if the controllers and the object are overlapping. Go to Components press Add Component and add a Box Collision. Select the Collision component, go to Details and under Collision, set Collision Presets to OverlapAll. Compile and Save and now you should be able to pick up the object.

 

 

 

 

Vive (Unreal Engine 4)

  1. Install the Vive App on your PC from: Get Started with VIVE
  2. Log in with either Steam/ Google/ Facebook Account
    1. If you have no account, register at: Welcome to HTC Account
  3. Get a room that is big enough:
    1. Minimum 2m x 1.5m
  4. Pick a spot to use as the play area
    1. Pick a spot for the sensors(Bases) and set them opposite of each other. (They will each need a power outlet)
    2. You will have to use the controllers that come with the headset or else they will not properly connect. You also have to be in SteamVR on the PC for the headset to turn on.
    3. The sensors should be above head level (Over 2m)
    4. Angled towards towards the play area at an angle of 30 - 45 degrees.
    5. Have unobstructed view of each others.
  5. Adjust the sensors
    1. If old one:
      1. Press mode on the buttons on the rear of the sensors and make sure that one is lit up with a B and the other with C. The light will be showing at the front of the camera.
    2. If it's the new one, they should automatically and be assigned letters.
  6. Connect the link box (The side that does NOT have orange ports)
    1. Use the HDMI cable to connect the link box to your computer
    2. Plug in a power cord and plug it into a power outlet
    3. Once it's connected to your computer, it should automatically start downloading and installing the drivers needed.
  7. Install headset
    1. The end of the headset has 3 in 1 tether of tree orange tipped cords. (USB, HDMI and Power). Plug in all these to the link box on the side WITH orange colored ports.
    2. After this, the computer will automatically start installing the drivers for the headset itself.

 

Integrating with Unreal Engine 4

  1. Open up Unreal Engine and select the Games tab under the New Project Categories header, then click next.
  2. Select the Blank from the Select Template and click next.
  3. Make sure you use Blueprint and choose the target platform as Desktop/ Console. You can choose if you want the starter content. For this example i will not be using the starter content. Choose a place to save your project and what to call you project. The press Create project.
  4. When everything has loaded. Delete the Player Start actor in the World Outline.
  5. Inside the Content Browser right click on Content folder. You will then get a drop down menu, Click the Blueprint Class tab.
  6. Inside the pick parent class, click the character button.
  7. This will be your player character in the game. I called my character PlayerCharacter. Make sure you name it something you will remember.
  8. Right click inside the Content folder inside the Content Browser again. Choose the Blueprint Class and now click the Game Mode Base. name it something you will remember. I named it VRGameMode.
  9. Drag you Character into the Level. You should now be able to put on your VR headset and look around in the Level. You will notice that you are at the same position as your Character. That is fine, it will be fixed later.
  10. Double click the Game Mode Base and  a new window will open Inside it. Under Classes, find the Default Pawn Class. Open the drop down menu and select your Character as the Default Pawn Class. Then press Compile and Save buttons in that order. You will know it has compiled once the button has changed from question mark to check mark.
  11. After this, we need to make sure that the Game Mode Base we made is the one in use. Click on Settings and World Settings. On the right side of the screen a menu will come.
  12. In the World Settings find Game Mode and change the GameMode Override to your Game Mode Base.
  13. In the World Outline select your Character. In Details make sure you have the Character selected and not any of the children. Scroll down until you find Pawn. Change the Auto Possess Player from Disabled to Player 0. If you play now, you will start where your Character is located.
  14. The next thing will be to add movement to your Character. We will make a Locomotion controller. Firstly, under the Settings tab, click the Project Settings… A new window will open.
  15. In Project Settings, go to the left of the screen and scroll down until you find Engine.
  16. Under Engine, find the Input tab.
  17. Now we must apply some inputs for the touch controllers for the VR headset. We will be able to move forwards, backwards, right and left with the joystick for the left touch controller. We will be able to rotate both right and left with the right touch controller. We will also be able to hold down a button to pick up some objects.
  18. To be able to move, go to Bindings and press the plus icon beside Axis Mapping. Expand Axis Mappings and name the Axis Mapping. I will call it Move_Forward. Expand the Axis Mapping and press the Select the key value. Find HTC Vive, expand it and select Vive (L) Trackpad Up. And you just do the same process with the rest. In the end it should look like the how it does on the picture beneath.
    PS: Remember to make sure that the Scale values are correct. Else the movement could become wrong.
  19. Close Project Settings. We will now make the inputs we defined work with the Character. Double click your Character to open it. You should have a window looking like this.
  20. First, delete all the nodes in the middle window. To create a node, you right click inside the window and search for the node you want. We want the inputs we made, so I search for Move_Forward. Make sure to select from Inputs and Axis Events. The node you get should be red. The next node is the Add Movement Input. The last node is Get Actor Forward Vector. After you have added all the nodes, connect them like this.
    • You also need to do the same with Backwards, just instead of searching for Move_Forward. You search for Move_Backwards.
  21. You can now press Compile and Save. If you play the game now you should be able to move towards where you are looking and backwards in the opposite direction.
  22. You can now do the same for the movement to right and left. Like it is done in the picture below. You should now be able to move left and right as well.
  23. Now we will make it possible to rotate with the right Vive Controller. Go to Input in Project Settings. Add a new Axis Mapping and bind Vive (R) Trackpad Right and Left. And set Vive (R) Trackpad Left value to -1.
  24. Inside your Character add your rotation input as well as an Add Controller Yaw Input. Connect them like shown below.
  25. Compile and save. You should now be able to rotate with your right Vive controller.
  26. Now it’s time to add the Vive controllers and make you able to grab some items with them.
  27. To add the controllers, you need to open your Character. Inside Components press Add Component and search for Motion Controller. Add one for each and call them something you will remember. I called them Right_Hand and Left_Hand.
  28. Select one of the Motion Controller components and go to the right of the screen to Details. Find Visualization and enable Display Device Model. In the Display Model Source, choose SteamVR. Then find Motion Controller under Visualization. Make sure that Motion Source is set to the correct hand. Do the same for the other Motion Controller.
  29. Select one of the Motion Controller components. Press Add Component and search for Box Collision and add it. Set the Scale of the Box Collision to 0.15 in Details and Transform. Do the same for the other Motion Controller. Press Compile and Save. You should now be able to see your controllers when playing.
  30. Go to Components in your Character and Add Component. Search for Camera and click it.
  31. The first thing you need to do is to make an Interface. The interface will be a way to determine if the object you are touching can be picked up. Right click inside the Content Browser and hover over Blueprints and click Blueprint Interface. Call it something you will remember. I called mine Interactible.
  32. Open the Interactible. On the right side inside My Blueprint make two functions. One grabbing up the object and one for dropping the object. I called mine Grab and Drop. When we grab the object, it should know what is grabbing it. Select the Grab function, inside Details press the plus icon beside Inputs. A new parameter will appear, call it something you will remember. I called it AttachTo. Change from a bool Parameter to a Scene Component as an Object Reference. The press Compile and Save.
  33. We will now make the hands be able to pick things up. I’m starting with the right hand. The first thing you need to do is to add some button inputs to check if you are grabbing. Go to Project Settings and Input. Press the plus icon beside Action Mapping. Add two actions. One for the right hand grab and one for the left. Call them something you remember. I called them Grab_Right and Grab_Left. For the Grab_Right add Vive (R) Grip, and Vive (L) Grip for Grab_Left.
  34. In your Character, right click, search for Grab_Right and add the InputAction Grab_Right. Then, right click and search for Grab and add Grab(Message).
  35. Right click and search for Drop and add Drop(Message). Search and add Get Overlapping Actors (Box_Right).
  36. Drag the Motion Controller component for the right hand into the field as well as it’s Box Collider. Search and add Get (a copy), and lastly connect the Nodes as done here.
  37. Do the same for the left Motion Controller component. Then Compile and Save.
  38. Now it is time to add the objects you can pick up. From Place Actors drag Cube into the level. Call it something you remember in the World Outliner and make sure it is Movable in Details under Transform. You can also scale it down like I have done under Transform. I scaled it to 0.25.
  39. In Details, click the Blueprint/Add Script button. Give it a name and press Select
  40. After the new blueprint has opened, go to Event Graph. Delete the existing Nodes, but before adding new nodes we need a reference to the interface we made earlier. Click Class Settings, in Details find Interfaces and add the interface we made. Press Compile and Save.
  41. Right click inside the Event Graph, search and add Event Grab. Then add a Set Simulated Physics node. This node should generate a Static Mesh Component. Keep this node and add it if you do not get it. Search and add an AttachComonentToComponent node, as well as a Root Component node. Then connect them like this.
  42. We have now made it possible to grab this object, but not to drop it. Search and add Event Drop, as well as a Set Simulated Physics node with the Static Mesh Component node. The last node will be DetachFromActor. Connect them like this.
  43. There is one more thing we need to do before we can pick up this object. That is to give it a collider in order to check if the controllers and the object are overlapping. Go to Components press Add Component and add a Box Collision. Select the Collision component, go to Details and under Collision, set Collision Presets to OverlapAll. Compile and Save and now you should be able to pick up the object.

 

 

 

 

 

 

AR Android

Activating Developer Mode (Phone)

Developer mode has to be activated for Unity to be able to send files directly from Unity/ Unreal Engine to the Phone when building in Unity and also to get a connection.

  1. Go to settings on your phone.
  2. Find build number and tap it 7 times to activate developer mode for your phone.
    1. Stock Android: Go to Settings > About Phone > Build Number.
    2. Samsung Galaxy: Go to Settings > About Phone > Software Information > Build Number.
    3. HTC: Go to Settings > About > Software Information > More > Build Number.
    4. LG: Go to Settings > About Phone > Software Info > Build Number.
  3. Once this has been done, a message should pop up on your screen: "You are now a developer!"
  4. Go back to Settings, where you will now find another button that has appeared on your screen. This button is at the bottom of the menu and is called Developer Options.
  5. Activate USB Debugging, this can be done by Going to: Settings > Developer Options > USB Debugging.

Setting up Unity on you computer

  1. Open up a new project.
  2. Go to package manager: Window > Package Manager.
  3. At the top bar of the new window, click on Advanced > Show Preview Packages.
  4. Install AR Foundation.
  5. Install the following packages in Unity depending on the Operating System your phone is running:
    1. Android: ARCore XR Plugin.
    2. iOS: ARKit.
  6. Close the window you are currently in.
  7. Go to: Edit > Project Settings > Editor > XR > ARCore
    1. Press the Create button.
    2. Change Requirement from Required to Optional.
  8. Delete the Main Camera in the hierarchy.
  9. Go to: Hierarchy > Create > XR > AR Session and AR Session Origin(In newer Unity versions the Create button has been replaced with a + button instead).
  10. Select the AR Session Origin, go to the Inspector on the right side of the screen and click Add Component. Search and add AR Plane Manager.
  11. Inside the Inspector right click and add XR > AR Default Plane.
  12. Make the AR Default Plane a child of the AR Session Origin.
  13. Select AR Session Origin. Drag the AR Default Plane into the Project panel to make it a prefab. Drag that prefab into the Plane Prefab field in the Inspector.
  14. Navigate to build settings: File > Build Settings  and choose either iOS or Android based on which platform you are making the game for.
  15. After having chosen the platform you want to build for, press  Add Open Scenes. (This adds the current scene you have open to the game when you build)
  16. Plug you phone to the PC with a USB Cable
  17. Once the phone has been connected to your PC, press Refresh beside  Run Device. Once that has been done, your phone should show in Run Device list.
  18. Press the Switch Platform button if the Build and Run button is grayed out.
  19. Close the current window
  20. Go to: Edit > Project Settings > Player > Other Settings > Graphics APIs and Remove Vulkan by clicking on it and then the - sign beneath it.
    1. Vulkan might create errors when trying to build the game for the phone if not removed.
  21. Navigate to build settings: File > Build Settings and press Build and Run.

Setting up Unreal Engine 4

  1. On the phone:
    1. Connect you phone to the computer and make sure to give the computer full access to your phone.
  2. On the computer:
    1. Download and install Android Studio from https://developer.android.com/studio.
    2. Open Android Studio and press Configure and SDK Manager.
    3. Make sure that Android 9.0 (Pie) is installed.
    4. Now, go to C:\Program Files\Epic Games\UE_4.25\Engine\Extras\Android. Here you should find a SetupAndroid.bat file. Open it. It should open the Command Prompt and automatically install the SDKs you need. If it asks you to accept, press “y”.
    5. After the Command Prompt has finished, you can open Unreal Engine 4. Start a new games project, use a Blank template. A window called Project Settings will open, make sure that you are using Blueprint and that the target platform is Mobile / Tablet. I also used Scalable 3D or 2D. Name your project at the bottom and hit Create Project.
    6. Inside Unreal, find Settings and open Project Settings. Inside Project Settings, on the left hand side, scroll down until you find Android under Platforms. Under APK Packaging, there should be a red box. Inside there press Configure Now so it turns green. Also make sure to press Accept SDK License, so it appears semi transparent.
    7. Under Platforms go into Android SDK. Here you must put in the path to the Android SDK, the Android NDK and JAVA.
      1. For the Android SDK location, I used C:/Users/[username]/AppData/Local/Android/Sdk
      2. For the Android NDK location, I used C:/Users/[username]/AppData/Local/Android/Sdk/ndk/21.1.6352462 (The numbers will probably be different for you)
      3. For JAVA i used C:/Program Files/Android/Android Studio/jre
    8. Now close Project Settings. Find Settings and go to Plugins. Inside Plugins search for Google ARCore.
    9. Check the Enabled box and press Restart Computer Now.
    10. Now, you need to make three blueprints. Create a blueprint by right clicking inside the Content Browser and clicking Blueprint Class. You will get a window where you can choose what type of blueprint you want. You need a Pawn, a Player Controller and a Game Mode Base
    11. Open the Game Mode and on the right side of the window, under Classes, that Player Controller Class is set to the Player Controller you just made. Also change the Default Pawn Class to the Pawn you just made. Press the Compile and Save buttons and close the Game Mode.
    12. Find Settings and open Project Settings. On the left side, under Project, find Maps & Modes and click it. Set the Default GameMode to the Game Mode Base you created.
    13. Now that the Game Mode is set up, you need to add an AR Session. In the Content Browser, right click and inside Miscellaneous, click the Data Asset. A window will appear. Pick the ARSessionConfig and name the Data Asset you created.
    14. Go into the Pawn you created and on the left side, inside Components, press Add Component and search for Camera. Add the Camera.
    15. Go into the Event Graph. Inside the Event Graph, right click, search and add Start AR Session. Inside the node add the Session you made earlier. Connect that node to the Event BeginPlay.
    16. Now drag out from the Event Tick, search and add Get All AR Geometries. Search and add a For Each Loop in addition to a Debug Draw Tracked Geometry. Inside the Debug Draw Tracked Geometry, choose what color you want. Make sure that it is not the same color as the surfaces in the room you are going to test the AR functionalities. Then connect the nodes like this.
    17. Before we can test the AR on the phone, we need to make a map for the game to take place in. Right click inside the Content Browser and add a Level and name it. 
    18. Find Settings and go into Project Settings. On the left, under Project, find Maps & Modes. Under Default Maps, set both the Editor Startup Map and the Game Default Map to the map you created. 
    19. Now you can package the project and test it on your phone. In the top left corner, go to File, Package Project, Android and choose Android (Multi: ASTC,DXT,ETC2).
    20. Find a place to save the package and press Select Folder. Wait for Unreal to finish Packaging. Connect your phone to the computer and make sure that the phone is willing to share files. Then double click the Install_[project name]-arm7.bat. When it is done you will have an app on your phone that you can test. Move your phone around and you will see that it is tracking space when the squares and rectangles that are being created.

 

De-Activating Developer Mode (Phone)

  1. Go to: Settings > Developer Options > Switch slider from ON to OFF.
  2. Developer mode is now inactive until activated again.

 

 

Read More

  1. Documentation for the different development programs that Oculus supports: Link
  2. Unity interface explanation: Link
  3. Unreal Engine 4 interface explanation: Link
  4. About developer mode and configurations on android: Link
  5. AR documentation for Unity: Link
  6. VR documentation for Unity: Link
  7. AR documentation for Unreal Engine 4: Link
  8. VR documentation for Unreal Engine 4: Link