Nicholas Barnes
Jul 8 · 3 min read

Onsite weeks 11 + 12

Unity for Gear VR on MacOS

Setting this up was a faff, but here are the steps that work, excluding the many that didn’t:

  • Download Unity Hub
  • Download Unity 2018.3.14f1, not a more recent one! Include Android deploy tools
  • Open Android Studio if it downloaded with Unity, download it and open it if not.
  • Tell it to download the recommended packages including sdk
  • When it has finished, exit the program
  • Navigate to user/Library/Android
  • Open the folder in finder with open .
  • Add the sdk folder to finder favourites (drag it over) so it can be found easily
  • In Unity hub, make a new 3d project using the specified Unity version
  • In File/Build settings, switch the platform to Android
  • In Edit/Projects settings/ Player settings/xr, check the virtual reality box and add Oculus sdk with the little plus
  • In Edit/Project settings/Other settings, enter a product name like com.Test.test, and set the android version min to 5.0

Time to set up the device:

  • Plug your Android phone into the gear VR to trigger necessary downloads, create an Oculus account when prompted to.
  • Meanwhile, run this in terminal:

brew cask install android-platform-tools

  • When your phone has finished installing Oculus stuff, attach it to the computer and run this in terminal:
adb devices

Back in Unity:

  • Make a new directory: Assets/Plugins/Android/assets
  • Put the oculussig file in that new directory
  • In the build settings, add the current scene
  • Build and run the project. This should ask you where the Android sdk is unless it found it already. Choose the one you added to finder favourites.
  • Save the build
  • Let it build and deploy to your device
  • Put your phone in the Gear VR headset

Maze Generation

As a challenge to ourselves and to make the game more replay-able, we decided to have a new maze created every time someone started a game.

Initially started by populating a whole grid of walls:

void PopulateGrid(){  for(int x = 0; x < gridSize; x++)  {    for(int z = 0; z < gridSize; z++)    {      Debug.Log($"This is line {x}, row {z}");
Instantiate(tile, new Vector3(x * 5, 0, z * 5), Quaternion.identity);
} }}

This was run once in Start(), after declaring gridSize in the editor. This had a lot of duplication of walls and it wasn’t going to be fun trying to go through and delete them, so we looked at some algorithms online and then designed our own:

// 1. create a start tile and assign it as the current tile for reference// 2. create it with all four walls// 3. add it to a list of tiles// 4. choose a random viable direction://      not outside the maze size(check x and z)//      not already instantiated(check the tile list)// 5. delete the wall of the current tile that leads to the next tile// 6. assign the current tile as the previous tile for reference// 7. instantiate the next tile and assign it as the current tile for reference// 8. Delete the wall of the current tile that leads to the previous tile// 9. add the current tile to a list of tiles// repeat 4 - 9, until there is no viable direction for the next tile

The idea is this runs through the available space, creating a route the player can move through, until it gets stuck and cannot make another tile. Then, it has to find a new starting position:

// Make a list of all possible spaces in the grid// Add to a list of occupied spaces whenever a new tile is created// To find an empty space, compare the lists// Find a connecting tile by the empty space, or find a new space if there isn't one// Remove the walls connecting them to create a branching corridor

To place the treasure, we took inspiration from Djikstra’s pathfinding algorithm.

Nicholas Barnes

Written by

Artist and software developer, currently a senior at Makers Academy, London. insta: @n3ttl3t