Unity 3D Game Development Tutorial: Build Your First Game

Jan 13, 2026Tutorial

Unity 6 are here, and it's more powerful than ever. In this tutorial, we will build a simple "Endless Runner" game to teach you the core concepts of Unity engine, C# scripting, and mobile optimization.


1. Setting Up Unity Hub & Editor

First, go to unity.com and download Unity Hub.

  • Install Unity Hub.
  • Go to Installs > Install Editor.
  • Choose the latest LTS (Long Term Support) version (e.g., 2026.1 LTS).
  • Important: Check "Android Build Support" (OpenJDK & SDK/NDK tools) if you want to deploy to mobile.

2. The Interface: Finding Your Way Around

When you open Unity, you'll see several windows:

  • Scene View: Where you build your world visually.
  • Game View: What the player sees through the camera.
  • Hierarchy: A list of every object in your current level (Scene).
  • Inspector: Shows settings/properties for the selected object.
  • Project: Your file browser (assets, scripts, sounds).

3. Creating the Player (The "Cube")

Right-click in the Hierarchy > 3D Object > Cube. Name it "Player".

To make it move, it needs physics. With the Player selected, look at the Inspector, click Add Component, and search for Rigidbody.

4. Writing Your First C# Script

In the Project window, right-click > Create > C# Script. Name it "PlayerMovement". Drag it onto your Player object.

Double click to open it in Visual Studio. Paste this code:


using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float speed = 10f;
    public Rigidbody rb;

    void FixedUpdate()
    {
        // Move forward automatically
        rb.AddForce(0, 0, speed * Time.deltaTime);

        // Move left/right with input
        if (Input.GetKey("d"))
        {
            rb.AddForce(500 * Time.deltaTime, 0, 0);
        }
        if (Input.GetKey("a"))
        {
            rb.AddForce(-500 * Time.deltaTime, 0, 0);
        }
    }
}

5. Adding Obstacles & Collisions

Create another Cube, resize it to look like a wall, and place it in front of the player. Name it "Obstacle".

Create a script called "PlayerCollision". We will detect when we hit something:


using UnityEngine;

public class PlayerCollision : MonoBehaviour
{
    void OnCollisionEnter(Collision collisionInfo)
    {
        if (collisionInfo.collider.name == "Obstacle")
        {
            Debug.Log("We hit an obstacle!");
            // Restart level logic here
        }
    }
}

6. Building for Android

Ready to play on your phone?

  1. Go to File > Build Settings.
  2. Select Android and click Switch Platform.
  3. Click Build. Name your APK file.
  4. Transfer the APK to your phone and install it!

Next Steps

Congratulations! You just built the prototype for a hit game. Next, try adding a score system, better graphics from the Asset Store, and sounds.