So, previously our plan was to just create a normal 3D puzzle adventure game. But, that idea escalated when both Tim and I got Virtual Reality headsets in December.
Since then, I’ve been playing about with VR development in Unity for a while and then we decided to turn our final major project into a VR puzzle game.
In this post, I’m going to talk about the process of making one of my puzzles, Totem Heads, work in VR.
In case you don’t know what Totem Down is, the puzzle consists of the following:
- A master totem in the middle of the puzzle
- Single totems that need to be rotated to the face the master totem
- Some totems have additional totems of them, making them a connecting totem
- The puzzle is completed by rotating all the totems towards the center
Now that’s out the way, lets talk a bit about Virtual Reality.
Let's get moving
The first hurdle that I needed to tackle was movement. In our game, we want our player to be able to move about freely within the level. There were a number of solutions available to us.
- Teleportation – Available within the SteamVR Package
- Artificial Locomotion using the joystick/touch pad
- Arm-Swinger Locomotion
I had previously played about with the teleportation idea, but the problem was that it would break immersion. Instead I chose to start implementation with the arm-swinger method.
The way this would work is:
- Check for controller input for specified button (in this case I’m using the Oculus touch with the bindings set up for A and X).
- Store the location of the controller on button press
- As the controller is moved with the button press, calculate the distance between the start and current location
- Apply that amount of movement to the player rig.
To get an idea of how it looks, I’ve recorded some footage from within my test scene that has a simple implementation of it.
One thing to note when doing this method, is that you need to set up some dead zones for the minimum amount of controller movement to move the player. Otherwise you will constantly be moving the player if they hold the controller as still as possible.
Turning the Totem
So, now that i have movement in VR, I can go ahead and convert the totem heads puzzle to be compatible with my controllers.
A good thing about the SteamVR plugin, is that it has an examples scene to show you what you can potentially do with the plugin.
The key thing that I’m going to use from the plugin is the Circular Drive component. This component acts as a hinge joint in VR. All I needed to do, was to add a circular drive to the totem, and then set rotation axis to Y. This ended up giving me a nice VR Puzzle that you can see below.