Entering & Building the Virtual Maze

Alishba Imran
Dec 6, 2018 · 4 min read

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.


Maze Game Demo Clip

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.

Environment

View of the mountains in the game

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.

Ground

Movement pauses when the user looks down

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.

Boundaries

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

Walking

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.

Navigation

The Capsule Collider Component in Unity

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

Raycasting

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.

Alishba Imran

Written by

Passionate 15-year-old on a journey to solve the world’s most important problems.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade