Labyrinth game in Unity 3D with Leap support
4.4 (10 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
95 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Labyrinth game in Unity 3D with Leap support to your Wishlist.

Add to Wishlist

Labyrinth game in Unity 3D with Leap support

Make a digital version of the labyrinth game in Unity 3D with Leap Motion device support for an immersive interaction.
4.4 (10 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
95 students enrolled
Created by Dessain saraiva
Last updated 6/2017
Current price: $10 Original price: $20 Discount: 50% off
4 days left at this price!
30-Day Money-Back Guarantee
  • 1 hour on-demand video
  • 4 Articles
  • 1 Supplemental Resource
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Make a digital version of the labyrinth game in Unity 3D with Leap motion device support.
  • Know how to integrate the Leap Motion SDK in their Unity 3D projects.
  • Be more confortable creating Unity 3D projects duo the several tips given along the course.
View Curriculum
  • A basic understanding of the Unity 3D software and some Javascript.

In this course we will build from scratch a digital version of the famous labyrinth game board in Unity 3D. We will set the scene, camera and code the interactions with Javascript to have Leap Motion device support to make your game even more immersive and challenging.
You will gain unity 3d skills by building the scene, configuring the set and code the game engine (keyboard and Leap) from scratch we will use Javascript and C# languages being the code as simple as possible so almost anyone can complete this course.
Do you want to make a game and start integrating Leap motion in your Unity 3D projects ? Then this is the course for you because we will build a fully functional video game that you can easily improve being your imagination the limit!

If you subscribe to any of my course just send me a message and I'll send you a FREE VOUCHER to another course I've made and since it's almost holidays here's a 50% discount voucher (GAMEDEV) for this course, limited amount available!

Who is the target audience?
  • This course is meant for Unity 3D newbies or intermediate users who want to start using the Leap Motion device in their projects.
  • Users with no experience at all in Unity 3D might encoutner some problems to finish the course.
Students Who Viewed This Course Also Viewed
Curriculum For This Course
15 Lectures
3 Lectures 02:58

My name is João Dessain Saraiva and I'm a web developer from Portugal, I work with IT since 2001 and have a master degree in multimedia. In my master I had the chance to develop a virtual reality experience using the leap motion device to control the character and a Oculus Rift headset to immerse the player. This among other projects gave me the expertise to start taking part in other projects and be able to share my knowledge with others.

Preview 01:00

Brief description of what the project is intended to be and how it will look in the final.
How the scene will look, the timer, motor engines (keyboard and Leap) game engines scripts.

Preview 01:52

This is a game development project that uses Unity 3D software, Javascript language and Leap Motion for interaction, Leap is not a mandatory accesory.

What you need to have and know
Games scene and engine
3 Lectures 21:30

Create the new Unity 3D project, game board and sphere.
To easily look around Unitys scene click the right button of the mouse and press the W key to go forward S backward A to the left and D to the right, you can move fast by pressing the shift key; to pan around click the middle mouse button.

Create new materials by clicking the right button on the projects pane and New -> Material. You can apply the material in an object by dragging it into the object, you can also select the material by choosing it in the game objects panel.

Set the camera position by using the directional arrows and rotate it using the according tool. scene is ready!

Preview 03:28

Looking around the scene
1 question

Let's write some code and move the game board with our keyboard, first we will change the game objects name by clicking on it and change the name on the game object panel or by clicking F2.

To apply physics to the Sphere we will select it and apply a Rigidbody by going to Add Component and select Rigidbody, we will leave the default values. We will also apply a Rigidbody to the game board, however you need to uncheck use gravity and freeze position and rotation so the board won't move around.

To add a script to the game board, select it and go to Add Component and type "engine", since it's a word Unity doesn't recognize it will suppose it's a script, select Create and Add and a new script will be attached to the game board, you can open it by clicking the scripts name.

Inside the script we will delete the default values and create a new variable (rotation) that will hold the rotation's speed. Inside function Update we will check for every key press on W and if so rotate the game board forward.

public var rotateSpeed: float = 1;

function Update(){
if (Input.GetKey("w"))
transform.Rotate(vector3.forward, rotateSpeed * Time.deltaTime);

if (Input.GetKey("s"))
transform.Rotate(vector3.back, rotateSpeed * Time.deltaTime);

if (Input.GetKey("d"))
transform.Rotate(vector3.right, rotateSpeed * Time.deltaTime);

if (Input.GetKey("a"))
transform.Rotate(vector3.left, rotateSpeed * Time.deltaTime);


Save the script and test it.

Preview 08:12

We have the game working, now let's had some barriers and the goal mark to where the player has to direct the ball.

Create the barrier by going to Game Object -> 3D Object -> Cube, place it in the middle of the game board and set the same size as the game board (scale X 20) now place it in the game board borders and shrink it a bit, change the game object name to barrier. Duplicate the barrier by going to Edit -> Duplicate, to this for the remaining borders. Place the barriers inside the game object by selecting them and dragging them into it, now the barriers will move along side the game board.

Create new materials on the Project panel by clicking the right mouse bottom and choose New -> Material, use the colour picker to have a colour in the barriers that resemble the game board, apply the materials on the barrier game objects.

Create the game goal by going to Game Object -> 3D Object -> Cylinder scale the X and Z to 3 and shrink it using the transform tool, create a new material with a vivid colour and apply to the goal object, place it inside the game board object and change it's name. Create a new script by having the Goal selected and going to Add Component and call it Goal (use Javascript) open the script, erase it's content and type:

function OnCollisionEnter (col: Collision) {

Debug.Log("we have contact");


Add a rigidbody the the Goal game object by selecting it and go to Add Component -> Rigidbody uncheck Use Gravity and check Is Kinematic. Remove the Capsule Collider by right clicking it and choose Remove Component, add a Mesh Collider in Add Component, this way the action radius will be around the object mesh.

Building the level, setting goals.

Change game objects name
1 question
Leap Motion device integration
3 Lectures 08:24

Download the plugin from Unitys site

To Import the SDK to unity go to Assets -> Import Package -> Customer package select the file you downloaded from the website, you can import some demo scenes or just the plugins to make Leap work in Unity like we are doing; in the project panel you can see the newly created folders and files.

Leap installation and configuration in Unity 3D

In this lecture we will adapt the Leap Motion device to our game.
Select game board and add component and type Engine an choose C# as programming language, open the created script, the code will be the following:

using UnityEngine;
using System.Collections;
using Leap;

public class engine_leap : MonoBehaviour {

Controller controller;

void Start() {
controller = new Controller();

void Update() {

Frame frame = controller.Frame();
Hand rightMost = frame.Hands.Rightmost;
Hand leftMost = frame.Hands.Leftmost;

transform.rotation = Quaternion.Euler (0,0, rightMost.PalmNormal.Roll * 3);

transform.rotation = Quaternion.Euler (leftMost.PalmNormal.Roll * 3 , 0,0);



Create a game engine for Leap Motion

Scripting languages in Unity project
1 question

Check the results of our game engine with Leap support.
Use the right hand rotation to move the game board forward and backward and the left to control the side rotation.

Extras and challenges
4 Lectures 19:33

Final check of the scene and code, set some barriers on the scene.
Center the game object position to 0 to make sure it's right in the middle of the scene, position the camera, check the result; we can remove the versus 3 multiplication from the Leap engine to make the game smoother.

Build your scene by duplicating the current barriers, rotate them and place as you which.

Create the goal text by going to Game Object -> 3D Objects -> 3D text and place the text in front of the camera, change the text and click play to check it's position, call the game object goal_text. We want to show the text only when the player reaches the goal, open the goal script on the goal game object and add the following code:

public var goal_txt: GameObject; = false;

Choose the goal_text game object on the goal panel, you might need to deselect and select the object for this property to show. Back on our goal script, remove the message and type: = true;

Build the level, improve the game

A timer will start counting from the beginning of the play until the player reaches the goal.

Duplicate the goal text and change the name to timer_txt (always a good practice to define the element type within its name ) place and rotate as you seem fit and type 0 on the text.
To make the timer start counting we will create a new script attached to the timer game object, in javascript and call it counter, open it and the code will be the following:

public var time : float;

function Update(){

time += Time.deltaTime;

var minutes : int = time / 60;
var seconds : int = time % 60;

GetComponent (TextMesh).text = String.Format ( "{0:00}:{1:00}", minutes , seconds);


Click play and check the results, the timer is counting (hopefully).
We now need that the timer stops when the ball reaches the goal, go to the goal script and add:

var counterScript: counter;

function OnCollisionEnter (col : Collision) {

counterScript.counterActive = false;


When the player reaches the goal the counterActive boolean inside the counter script will become a false.
Back to our counter script we will start checking if the counterActive is false and stop the timer when it's.
Inside the function update insert the conditional:
if (counterActive == true) { }

Don't forget to select the timer_txt game object where the counter ccript is on the goal game object panel. And place the timer code inside this conditional, I am not typing the whole code on propose ;)

Set a game timer

By now you will have a full functional version of the labyrinth game in Unity 3D made by you!

Thank you for making this course and your feedback is greatly appreciated and remember software development is a never ending process of improvements and corrections..

Thank you!

Project Files
Orion SDK
2 Lectures 15:23
Updating to Orion SDK

Updating to Orion SDK - description
About the Instructor
Dessain saraiva
4.5 Average rating
19 Reviews
153 Students
3 Courses
Web developer and Virtual Reality enthusiast.

Hey, my name is João Dessain Saraiva and I am developer from Portugal. I been coding since 2001 and playing video games since I was 8, started in a ZX Spectrum all the way to the last Xbox and even my master degree project in design and multimedia was an immersive ski video game that uses a Oculus Rift headset and a Leap device to control the movements of the character.
Udemy now gives me the chance to share some of my knowledge and expertise in Unity 3D, video games and Virtual Reality however I also intend to learn a lot more from the community and keep improving as I teach.