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
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.
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
Scene View:
- This is where you build and arrange your game objects. You can navigate the scene view using mouse and keyboard shortcuts.
Game View:
- This shows what your game will look like when it’s played. You can test and debug your game here.
Hierarchy:
- Lists all the game objects in your scene. You can organize game objects into parent-child relationships.
Inspector:
- Displays properties of the selected game object. You can add components, change properties, and customize your game objects here.
Project Window:
- Shows all the assets in your project. You can organize assets into folders and import new assets from your file system.
Console:
- Displays debug messages, warnings, and errors during development.
Basic Concepts
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.
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.
- Scripts, renderers, colliders, and other elements that add functionality to game objects. For example, a
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.
- Files used in your game, including models, textures, audio clips, scripts, and more. Assets are stored in the
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
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.
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.
- The base class from which all Unity scripts derive. It provides methods like
Basic Workflow
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).
Scripting:
- Write C# scripts to control game mechanics.
- Attach scripts to game objects by adding them as components.
Testing:
- Use the Play button in the Unity Editor to test your game in the Game View.
- Debug and iterate based on test results.
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
Rigid Body
5. Adding textures to Gameobject
7. Local/Global and Pivot/Center tools 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
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
Post a Comment