How to

How to make a game on Unity: starting with a simple 3D maze game

How to make a game on Unity: starting with a simple 3D maze game

Ever wanted to learn how to make a game at Unity? Unity is a powerful cross-platform game engine, and a development environment that supports most games on the Google Play Store. Through Unity, users get access to ready-made physics, rendering, controls, and more. This can drastically accelerate the development process. Thanks to tools like Unity, indie developers can finally compete with the big studios again.

That can mean you! So, read on to learn how to make games on Unity.

How to make a basic game in Unity – settings

This tutorial will assume that you are familiar with Unity software and how it works. If you need more background about it and want advice on how to navigate a UI that is crowded, then check out our introduction to Unity.

For this tutorial, we will develop a top-down game that makes players navigate the map to find keys. This is the first major project at Unity for beginners that will teach you some basic concepts.

For this reason, the game will become 3D. Start a new project, and make sure you have selected “3D” under the template. (Unity used to be called Unity 3D, but today it’s just as popular for 2D development.)

Unity tutorial for beginners – build a maze

Now we will arrange some items in our scene. First, we will add to the ground, which is called a 3D plane in Unity-speak.

To add this to the scene, go to:

GameObject> 3D Objects> Plane

This will drop a flat square into your scene. “Landscape” is effectively another word for levels at Unity, although that can also refer to things like menus. The scene window allows you to see and manipulate individual elements that exist in the world of your game.

Next, we will add some cubes. Enter the first one by entering:

GameObject> 3D Objects> Cubes

This will insert a cube which by default will appear right in the middle of the plane. To move an element, you can select it in the scene, and then choose the arrow icon in the top left. This will then allow you to drag items on all three axes.


However, for our purposes, we can truly leave this place! Now you will make more from these boxes. To do this, highlight the first one and click Ctrl + C. Now press Ctrl + V to paste and a new cube will appear directly above the old one. You will know this works because you will see another cube now listed in the hierarchy on the left. The hierarchy is basically a list of everything in your scene, which makes it very easy to find and manipulate individual items. When you become a pro in Unity development, everything you need to think about organizing these elements makes sense. If not, this can be a little busy!

Drag the highlighted cube away from the first cube so that it’s directly next to it without gaps. To do this precisely, you need to hold down the Ctrl key while you drag. This causes the object to move with predetermined units, all of which can be controlled in the settings.

Our goal is to make a maze, so drag some around this to make something that looks like a maze and is challenging. Characters will start at the top left.


If this is done a little from a fixed angle, hold down the Alt key and then drag with the mouse to change your point of view. You can also use the mouse wheel to zoom in and out.

Entering characters

Now you have a level, but to find out how to make a game on Unity, you also need to create a character that can be controlled. For the sake of simplicity, I’ll go with a small ball that can roll in a maze!

To make this ball, just put the ball in the scene when you add the box.

But this time, we want to give a form of physics. To do this, you only need to select it in the hierarchy or view view and then the “inspector” view that appears on the right. This window shows you the properties of each element selected and allows you to edit them precisely. This also allows you to add “components” to GameObjects, which means you can change their behavior.

Click “Add Component” and then:

Physics> Rigid Body.

RigidBody is a script that basically provides ready-made physics to be applied to any object. Our ball will now fall to the scene, ready to be moved! This is the true power of using a game engine like Unity 3D: it provides built-in features that would otherwise take several months to encode and maybe a math degree!

This is a good suggestion when learning how to make games on Unity: don’t try and reinvent the wheel. In fact, it applies to coding in general. If someone has built something that does what you need, use it!

I reduced the size of my standard sphere to 0.5 by editing the scale on all three axes in Transform (also found in the inspector).


Where you move the ball at the scene is where it will be placed at the start of the game. I want my ball to be level with the ground when the game starts, so an easy little “hack” that you can use to achieve this is to let the game play with the selected ball so you can see its properties change in the inspector when it falls. Then note where the Y axis ends after it settles on the ground. That must be your starting point!

Repair the camera and input

To play this game properly, we want to take action from the top down. To do that, we need to change the angle of the camera and the FoV. So select a camera in the Hierarchy and you will see a small window appear in your scene that shows a preview of what it is seeing.

This also opens up some details in “Inspector” on the right. Where it says “Rotation,” we will change the X-axis to “90.”

Now drag the camera up and away from your scene, until you can see the entire map.


But we still need a way to control our game! For that, we need to write our first script. It’s time to learn how to code in Unity!

Don’t worry, it’s really simple and you only need to copy and paste what you see!

Create a new folder in your Assets and call it “Script.” Now right-click anywhere here and choose:

Create> C # Script

Call your new script “TiltControl.”

After this is created, double click to open your default editor (IDE). This will usually become Visual Studio.

Now just delete everything that exists now and replace it with:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TiltControl : MonoBehaviour

    public Rigidbody rb;
    // Start is called before the first frame update
    void Start()
        rb = GetComponent();

    // Update is called once per frame
    void Update()

    void FixedUpdate()
        Vector3 movement = new Vector3(Input.acceleration.x, 0.0F, Input.acceleration.z);
        rb.velocity = movement * 5;

You don’t need to know everything that happens here, except that the “fixedUpdate ()” method runs at a fixed interval. Here, we call the Rigidbody component that we added earlier and then add speed to the three axes based on the accelerometer on the phone. In other words, players will now be able to move the ball around by tilting the phone!

Now back to Unity, select the sphere, and drag your TiltControl script to the Inspector at the bottom that says “Add Component.” This now means that the code in your script will affect the Game Object that you have attached.

And yes: that means you can easily cause the entire ball fleet to move when you tilt your phone!

Remember that this method is sensitive to the initial position of the phone – so you prefer to do something to calculate this before the application runs if you want to develop this further.

Before we test the game, you must also check the box that says “Freeze Position Y” under Constraints. This is important because it will prevent the ball from bouncing out of the maze if it moves too fast!

Make Android games on Unity for beginners

This is Android Authority, so we want to make an Android game!

To do this, choose File> Build Settings. Now highlight Android from the Platform list, then select “Change Platform.”

For this to work, everything you need to have Android SDK and Java JDK installed and on your machine. You can ask Unity to handle this for you at run-time, otherwise you have to download it separately and then search for the necessary files. This can also be achieved through the Unity Hub.


You also have to click on the button that says “Add Open Scenes,” which will add the level that you created to the build.

Finally, click on “Player Settings” and then scroll down to where it says Default Orientation. You want to set this to “Landscape Right” which will prevent the screen from rotating while your players are having fun!

To build and test an application, you only need to click “Build and Run” when your smartphone is connected. Make sure you enable USB debugging in the Developer Options menu.

If everything goes according to plan, then you will see the game appear on your device’s screen after a few minutes of building. Congratulations: Your first Android application built on Unity!

# Winning

But it is not a game until you can win! To add victory conditions, we will make one of our blocks a goal.

Drag and place the simple blue PNG box into your Project window (you can create a new folder called “Color” or something if you want). Select one of the boxes in your game then drag and place the color on it.

Now we need to create a new script, which I call “WinBlock.” This one looks like this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WinBlock : MonoBehaviour
    // Start is called before the first frame update
    void Start()

    // Update is called once per frame
    void Update()

    void OnCollisionEnter(Collision collision)


What this is doing, is checking to see if anyone has hit it. All of these cubes have “Colliders” by default, which is a limit that allows Rigidbody to know where obstacles start and end. This is another common feature of the video game engine that saves a lot of time for developers.

So when something new touches the limit, the game will come out! Seeing that the only thing that can move is our little ball, we can safely assume that this will be the culprit.

Of course, just leaving the game when you win is a bit rude. Ideally, you might play a sound and then launch the next level (which means creating a new scene).

What’s next?

There is much more you need to do to make this game fun – especially if it can be sold. We need to add textures, music, graphics, perfect gameplay. If we build this into a bigger project, we also need to reconsider how we organize the elements in our scene.

However, as a starting point, I think you will agree it is quite impressive what we have achieved in a very short period of time. And we have learned some basic lessons along the way.

This is the first game that you made with Unity!

10 Best Apps Like Ibotta To Save Money Android & iOS

Previous article

17 The Highest Free Payment Apps That Pay You For Android & iOS

Next article

You may also like

More in How to