No history yet

Unity Basics

Welcome to Unity

Unity is a powerful tool for creating games and interactive experiences. Think of it as a digital workshop filled with everything you need to build a world from scratch. Getting started can feel like a lot, but the interface is organized around a few key ideas. Let's walk through the main parts of your new workspace.

Lesson image

Your Digital Workshop

When you first open a project, you'll see several windows, each with a specific job. Understanding what each one does is the first step to feeling at home in Unity.

Here's a breakdown of the most important windows:

  • Scene View: This is your 3D canvas where you'll arrange all the objects that make up your game world. You can fly around, select objects, and move them into place.
  • Game View: This shows you exactly what the player will see when they play your game. It's your camera's live feed.
  • Hierarchy: A list of every single item, or Game Object, currently in your scene. Think of it as a cast and crew list for your level.
  • Project Window: This is your asset library. It holds all the files for your project: 3D models, images, sound files, and scripts.
  • Inspector: When you select an object in the Scene or Hierarchy, its details appear here. The Inspector is where you modify an object's properties, like its color, size, or behavior.

Building Blocks of Your Game

Everything in a Unity scene is a Game Object. By themselves, Game Objects are just empty containers. They don't do anything until you add Components to them.

Game Object

noun

A fundamental object in Unity that represents characters, props, scenery, cameras, or anything else in your game. It acts as a container for Components.

Components are what give Game Objects their functionality. A Game Object for a player character might have a component for its 3D model, another for physics so it can fall, and a script component to handle player input. Think of a Game Object as a blank potato head, and components as the eyes, ears, and mustache you attach to give it a personality.

Component

noun

A modular piece of functionality that can be attached to a Game Object. Components define the behavior and properties of objects in a scene.

Let's try creating a simple object. In the Hierarchy window, you can right-click and go to 3D Object > Cube. A white cube will appear in your Scene View. If you select it, you'll see its components in the Inspector. It will have a Transform component (which all Game Objects have) that controls its position, rotation, and scale. It will also have components that define its shape (Mesh Filter), make it visible (Mesh Renderer), and allow it to collide with other objects (Box Collider).

To add a new component, select your cube, go to the Inspector, and click the Add Component button at the bottom. Try searching for and adding a Rigidbody. This component tells Unity's physics engine to take control of the object. Now, if you press the Play button at the top of the editor to enter Game View, your cube will fall.

Making Things Move

To create custom behaviors, you need to write scripts. Unity uses the C# programming language. Don't worry if you've never coded before; we'll start simple. A script is just another type of component you attach to a Game Object.

Consider taking courses that focus on Unity development with C#.

Let's create a script to make our cube rotate. In the Project Window, right-click and select Create > C# Script. Name it Rotator. Double-click the script to open it in your code editor (like Visual Studio).

You'll see a template with two main functions: Start() and Update(). The Start() function runs once when the game begins. The Update() function runs once every single frame, making it perfect for actions that need to happen continuously, like movement or checking for input.

using UnityEngine;

public class Rotator : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        // Code here runs once at the beginning
    }

    // Update is called once per frame
    void Update()
    {
        // Code here runs continuously
        transform.Rotate(new Vector3(15, 30, 45) * Time.deltaTime);
    }
}

Let's add one line of code inside the Update function. The code transform.Rotate accesses the object's Transform component and tells it to rotate. Vector3 defines the rotation speed on the X, Y, and Z axes. We multiply by Time.deltaTime to make the rotation smooth and independent of the computer's frame rate.

Save the script and return to Unity. Drag your Rotator script from the Project Window onto your cube in the Hierarchy or Scene. Now, when you press Play, you'll see your cube slowly spinning. You've just written your first script and brought a Game Object to life.

Quiz Questions 1/5

Which window in the Unity editor is primarily used to view and modify the properties and components of a selected Game Object?

Quiz Questions 2/5

What is the fundamental relationship between Game Objects and Components?

That's the core loop of working in Unity: creating Game Objects, adding components to give them properties, and writing scripts for custom behavior. With these fundamentals, you're ready to start building.