Basics of Unity Game Engine

1. What is Unity?

Unity is a cross-platform game engine used to create 2D, 3D, AR (Augmented Reality), and VR (Virtual Reality) games and simulations. It’s known for its flexibility, visual editor, and support for multiple platforms — PC, consoles, mobile, and the web.

2. Core Components of Unity

ComponentDescription
SceneThe environment or level of your game; contains all game objects.
GameObjectThe basic unit in Unity — anything in the scene (player, camera, light, enemy, etc.).
ComponentBehaviors or properties added to GameObjects (e.g., Rigidbody, Collider, Script).
TransformDefines position, rotation, and scale of a GameObject.
PrefabA reusable template for GameObjects. Great for enemies, bullets, etc.
AssetExternal resources like textures, sounds, models, and scripts.
Tag and LayerUsed to identify or organize GameObjects in a scene.

3. Programming in Unity

Language: Unity primarily uses C# for scripting.

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    void Start() {
        // Runs once at the start
    }

    void Update() {
        // Runs every frame
    }
}

MonoBehaviour: The base class for all Unity scripts that interact with GameObjects.

4. Game Physics and Animation

5. User Interface (UI)

6. Lighting and Cameras

7. Scenes and Prefabs

Scenes can represent levels or menus. Prefabs allow you to instantiate multiple copies of GameObjects efficiently.

8. Unity Editor Interface

WindowPurpose
Scene ViewDesign and edit your level.
Game ViewPreview how your game will look when running.
HierarchyDisplays all GameObjects in the current scene.
InspectorShows properties and components of selected GameObjects.
Project WindowShows all assets in your project.
ConsoleDisplays debug messages and errors.

9. Building and Deployment

Unity can build your project for multiple platforms:

10. Learning Concepts