Entering & Building the Virtual Maze

Virtual reality technology is growing at an exceptional rate every day, and this is mainly due to the new realities it is bringing to our world. Virtual Reality is no more than a computer-generated world where your entire view is virtual. Over the past couple of days, I have been working on creating my own virtual project which I built for the Google Cardboard in the Unity Game Engine. My project is called The VR Maze Game, and essentially the user must try to navigate their way to the finish line.

The user is dropped into a spot in the maze, and they must continue playing until they get out of the maze.

Breakdown of the Game

While creating the game, the goal I had in mind was to create a simple project for beginners in VR but also to add a bit more challenge and fun into it.


The experience starts off by dropping the user inside the maze which is placed in the sky with a scene of mountains all around. The user is able to look around and navigate the entire maze without looking at it from the top to try and find the way.


The game comes with a bit of a trick. While the user is navigating around, if they do look at the group then their movement pauses. This makes it a bit more tricky for a user playing in real life because they must keep their head up for the entire game.


The game is not like any normal maze because technically you are “floating” in the air. It is important to stay on the maze and not go outside of the boundaries. If a user does, then the game simply starts again. There is a red and green arrow on the machine which helps the player understand the start (red) and end (green) of the game.

Building the Game


An update function gets called every frame. Using this function I was able to figure out how the user would navigate around the maze, how the camera would function with there walking, and what would appear on the screen. Essentially this code says that if there is walking, we move in the direction that the camera is facing.


The Capsule Collider can be used to ensure that the user can actually fit within the walls of the maze comfortably by assigning the space you want them to take up between the walls. In the scene, it looks like a camera icon which acts like the “player” and the radius and height can be manipulated to ensure navigation is done at an ease.

Boundaries Set-Up

Looking at the Ground

This invisible ray starts from the players position and is shot in the direction that the player is looking. In our game, the Ray cast helps us essentially identifies if the user is looking down at the plane which is the ground, and if they are the player's movement is stopped, or else they can continue.

Outside of the Plane

SpawnPoint is a name I set up in the code and represents the initial starting point on the maze. This way if the y position of the player in the Unity scene is less than -10, the user is automatically sent back to the spawnpoint (initial starting point) and the game starts all over again.

If you enjoyed reading this article, please press the👏 button, and follow me to stay updated on my future articles. Also, feel free to share this article with others!

Follow me on Medium and LinkedIn to stay updated with my progress in AR and VR.

I’m a developer & innovator who enjoys building products and researching ways we can use AI, Blockchain & robotics to solve problems in healthcare and energy!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store