Basics of Unity

Basics of Unity

Unity is a powerful and widely-used game development platform that allows developers to create both 2D and 3D games and applications. Here are some basic concepts and features of Unity to help you get started:

Getting Started with Unity

  1. Installation:

    • Download and install the Unity Hub from the Unity website.
    • Use Unity Hub to manage your Unity versions and projects. You can install the latest stable version of Unity or specific versions required by your projects.
  2. Creating a Project:

    • Open Unity Hub and click on the "New Project" button.
    • Choose a template (2D, 3D, URP, HDRP, etc.) based on your project requirements.
    • Name your project and select the location to save it, then click "Create".

Unity Editor Overview

  1. Scene View:

    • This is where you build and arrange your game objects. You can navigate the scene view using mouse and keyboard shortcuts.
  2. Game View:

    • This shows what your game will look like when it’s played. You can test and debug your game here.
  3. Hierarchy:

    • Lists all the game objects in your scene. You can organize game objects into parent-child relationships.
  4. Inspector:

    • Displays properties of the selected game object. You can add components, change properties, and customize your game objects here.
  5. Project Window:

    • Shows all the assets in your project. You can organize assets into folders and import new assets from your file system.
  6. Console:

    • Displays debug messages, warnings, and errors during development.

Basic Concepts

  1. Game Objects:

    • The fundamental objects in Unity, representing characters, props, environments, and more. Each game object can have multiple components that define its behavior and appearance.
  2. Components:

    • Scripts, renderers, colliders, and other elements that add functionality to game objects. For example, a Transform component defines an object’s position, rotation, and scale.
  3. Assets:

    • Files used in your game, including models, textures, audio clips, scripts, and more. Assets are stored in the Assets folder in your project directory.
  4. Prefabs:

    • Pre-configured game objects that can be reused throughout your project. Changes made to a prefab are propagated to all instances of that prefab.

Scripting

  1. C# Programming:

    • Unity uses C# for scripting. You create scripts to define game logic, behaviors, and interactions.
    • Scripts are attached to game objects as components.
  2. MonoBehaviour:

    • The base class from which all Unity scripts derive. It provides methods like Start(), Update(), OnCollisionEnter(), etc., which you can override to implement custom behavior.

Basic Workflow

  1. Creating a Scene:

    • Use the Scene View to place and arrange game objects.
    • Add components to game objects to define their behavior (e.g., RigidBody for physics, Collider for collision detection).
  2. Scripting:

    • Write C# scripts to control game mechanics.
    • Attach scripts to game objects by adding them as components.
  3. Testing:

    • Use the Play button in the Unity Editor to test your game in the Game View.
    • Debug and iterate based on test results.
  4. Building:

    • Configure build settings (target platform, resolution, etc.) and build your game to create a standalone executable or mobile app.

Resources and Learning

  • Unity Learn: Unity’s official learning platform with tutorials and courses.
  • Unity Documentation: Comprehensive reference for all Unity features and scripting API.
  • Community: Unity forums, Stack Overflow, and other online communities are valuable resources for troubleshooting and advice.

Practical

Link for Material: Link

1. Moving, rotating & scaling Game objects in Unity

2. Game Panel in Unity



3. Physics in Unity
        Rigid Body



4. Adding colors to Gameobject


5. Adding textures to Gameobject


6. Parent and child Game objects in Unity


7. Local/Global and Pivot/Center tools in Unity

8. Prefabs in Unity
Prefab is an asset which contains a blueprint of gameobject or gameobject family
Prefabs are created using existing gameobjects
A single prefab can be used multiple times in current scene as well as other scenes


9. Scripts - 
Rotating the spheres

MonoBehaviour : Link

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

public class RotateSphere : MonoBehaviour
{
    Vector3 movement;
    // Start is called before the first frame update
    void Start()
    {
        movement = new Vector3(0, 30, 0);
    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(movement);
    }
}

Time.deltaTime


10. Script:  Revolving the spheres




Comments