The 1978 classic handheld electronic memory game simon took the world by storm. While simple, it is addictive and fun. Since this was my first time with any VR technologies and being relatively new to Unity, I wanted to choose something I could finish.
What it does
The Oculus provides the Virtual Reality interface for you to have an immersive view of the game world. The Leap Motion sensor allows you to interact naturally with your hands in this world. Unity provides the physics, rendering, and gameplay control through GameObjects and scripts. The gameplay mimics that of the original simon game with the same tones and colors.
How I built it
I started by getting the Oculus drivers and Leap Motion SDK and Unity components setup on my dev machine so that I could experiment with the available demos and determine a general estimate of what I would be capable of completing in a little over 24 hours. I then started on the Unity VR samples and the Leap Unity samples and found an open source keyboard demonstration that showed a method for key press processing with the Leap Motion sensor. I decided to build my project off of this sample. Instead of pressing keys on a keyboard, I needed to press the simon buttons. I started by just editing the text on the buttons and consolidating down to 4 large buttons. This allowed me to start on the gameplay code.
I created a GameManager MonoBehavior that I used to handle game startup, playtime, and end game. I put in basic timing for these main stages and then developed the computer turn / player turn states and transitions. In simon the computer goes first and progressively builds a longer and longer sequence of color button presses. The user is then tasked with repeating the sequence in the exact same order. Each round gets one more random button pressed at the end as long as the user keeps getting the sequence correct. If the user makes a mistake the game is over.
Including here are worrying about timings to allow for enough time for the player to see the sequence and press buttons when it is their turn. Additionally, there are some game state metadata pieces to track like round number, running sequence, current score, high score, etc.
Challenges I ran into
The Leap Motion sensor is great, but it can be a bit flaky at times and with a game where you are not supposed to hit the wrong button, this can be frustrating for the player. Sometimes a random finger will poke out or the wrist will rotate or some other movement occurs that the user did not command. Likewise on button pressing, there were some challenges in timing how long to consider a button pressed and debounce such that a user would not accidentally double tap. I used a faster loop for detecting and handling player button presses and a slower loop for handling the game logic for the player and computer turns. This was very flexible and allowed me to design a fairly robust solution to the flakiness.
Another challenge was the versioning of the Leap Motion sensor itself and the documentation and samples related to these versions. Since the software is still at beta level, they have not ported all the old components that used to be available into the Orion Unity package. This is confusing because you can see samples of something you want to do but they are old and no longer work and basically just cause a distraction. Some of the features included in the main Leap Motion demo games (closed-source) are not included in the dev components that go with Unity. So you end up having to dig further into the details of operation of the sensor quicker than desired, especially during a short hackathon period. In general, I was still very happy with my choice of this sensor and VR headset.
Accomplishments that I'm proud of
I'm proud that I was able to make the complete game with sound effects. I was even able to add some easter eggs that take advantage of some of the fun factor portions of the Leap Motion sensor but are not related to simon. I used a wrist rotate gesture from the keyboard demo to bring up a menu that provides access to the extras including a ball dropper and a zombie spawner.
What I learned
I learned a ton about virtual reality, the Oculus Rift and the Leap Motion sensor. I got a lot more practice in Unity as well, which is great. My basic take home lesson is that I need to get this headset sensor setup for myself since development is fun and rewarding and there are so many possibilities for games to make.
What's next for SimonVR
I hope to show the game to the community and if people want to open source it for others. Hopefully, it can be a fun introduction to Oculus+Leap Motion for others in addition to being a fun game.