Labyrinth Game — Making a simple first-person game in unity

Updated information about this project

This arti­cle belongs to a series that con­sist on mak­ing a first per­son game about find­ing objects inside a maze. It's one of my very first series from the chan­nel. Now I reworked this project and you can down­load it to import in your own Uni­ty project. Some day I will make a new series about this project, sub­scribe to my chan­nel to see all the fresh con­tent about Blender, Uni­ty and pro­gram­ming.

Follow me on and download the source code of this project



Introduction of the old article

In this series we are going to cre­ate a sim­ple game in Uni­ty from scratch, the idea is to observe the tools that has the engine for cre­at­ing video games.

The series cur­rent­ly has 13 videos in the chan­nel and 11 arti­cles in which it is detailed step by step what is done in each video, so you can see quick­ly in video for­mat and ana­lyze the parts of inter­est in detail by con­sult­ing the articles.

Before I start I invite you to vis­it and sub­scribe to my chan­nel to find more videos about pro­gram­ming and 3D design.

Go to the Channel

Characteristics of the project

In prin­ci­ple we are going to cre­ate a first per­son game for the Win­dows plat­form, the sce­nario will be a labyrinth with sev­er­al entry and exit doors.

The char­ac­ter will start in one of the doors and will have to find a hid­den object in the labyrinth that will appear ran­dom­ly, when he finds it he will have to go through one of the doors.

There will be a time lim­it to ful­fill the objec­tive but inside the labyrinth there will be col­lec­table objects that will increase the time that the play­er has.

List of articles and videos

#1 – Introduction. 

We start a new project from Uni­ty HUB and talk a bit about the devel­op­ment envi­ron­ment. We import some ele­ments from the Stan­dard Assets pack­age and from Unity's Asset Store. We makea sim­ple scene using Uni­ty prim­i­tives and apply trans­for­ma­tions. We cre­ate mate­ri­als. We place the Stan­dard Assets pre­fab "First­Per­son­Char­ac­ter" in the hier­ar­chy. The project is con­fig­ured to compile. 


#2 – Import Assets. Configure Skybox.

We import the 3D mod­els and tex­tures pro­vid­ed in the down­load links and place them in the Uni­ty hier­ar­chy. We add the tex­tures to the mate­ri­als. We cre­ate Pre­fabs that are pre­fab­ri­cat­ed GameOb­jects that can be reused. We cre­ate a mate­r­i­al and con­fig­ure it to use it as Sky­box, with this we change the aspect to the sky of the scene. 


3D Models and Textures


#3 – Types of Colliders. RigidBody.

Add­Com­ponenet but­ton to add com­po­nents to a GameOb­ject. Dif­fer­ent types of Col­lid­ers, in par­tic­u­lar Box Col­lid­er, Sphere Col­lid­er and Mesh Col­lid­er. Char­ac­ter behav­ior when con­tact­ing Col­lid­ers. Rigid­Body com­po­nent and its rela­tion­ship with the Col­lid­ers. Col­lid­er behav­ior in Trig­ger mode. 


#4 – Place the character in a random position.

We set up a sys­tem to place the char­ac­ter at a spe­cif­ic point on the stage. Cre­ation of Tags or labels. Cre­ation of the first Script in C# that will have the func­tion of find­ing all the objects in the hier­ar­chy that have a cer­tain tag, sort­ing them in a vec­tor, ran­dom­ly select­ing one of those objects and plac­ing the char­ac­ter in the posi­tion of that object. 


GameControl script with comments


#5 – Create simple user interface. Canvas.

Cre­ate a sim­ple graph­i­cal inter­face with Can­vas. Two screens are made, one for the main menu and one for the game. Because the game is solved in a scene the screens of the inter­face are alternated. 


#6 – Programming of the user interface.

The user inter­face cre­at­ed in the pre­vi­ous video is pro­grammed. When you press the Start but­ton from the menu, the game starts. Use the escape key to return to the main menu. 


GameControl script with comments


#7 – Timer for the countdown.

We cre­at­ed a Timer in C#. Inter­ac­tion between Scripts, from one Script we exe­cute meth­ods belong­ing to another. 


GameControl and Timer scripts with comments.


#8 – Create, model and texturize terrain in Unity.

Cre­ation of ter­rain with relief and tex­tures. Ter­rain com­po­nent and tools. 


Download textures for the terrain


#9 – Place object in random labyrinth position.

Strat­e­gy for plac­ing an object at a ran­dom point in the labyrinth. 


Scripts GameControl, Timer and LabyrinthPiece with comments


#10 – Place collectables in random labyrinth positions. 

Place col­lectible objects on Uni­ty. Sys­tem of cre­ation and destruc­tion of the col­lec­tables. Effect when col­lect­ing them. 


Scripts GameControl, Timer, LabyrinthPiece and Clock with comments.


#11 – Special programming challenge for Halloween

This video con­sists of a spe­cial chal­lenge in which we will add a lit­tle fear to the project. Some­where in the labyrinth there will be a spe­cial pedestal, which will con­tain Lucy's remains. If the char­ac­ter encoun­ters this, Lucy will appear and chase after him. Every­thing that is done in this video will not be used in lat­er videos.

See the concept of this programming challenge

It's a much longer video than the oth­ers because a lot of things are done. Import Assets, con­fig­ure mate­ri­als and ani­ma­tions, Scripts.


GDT Halloween Pack


Scroll to Top
Secured By miniOrange