title | marp | paginate | math |
---|---|---|---|
Unity Basics 2. Unity's building blocks |
true |
true |
mathjax |
- Unity games consist of Scenes
- Scenes consist of GameObjects
- GameObjects consist of Components
- Manual: Scenes
- Scene is a container for content
- A game can be just one scene, or a combination of multiple ones
- Example scenes:
- Main Menu
- Level
- Game Over
- Create New Scene: Assets > Create > Scene
- New scenes use Unity's default Scene template, but you can create your own
- Manual: GameObjects
- Pretty much everything in Unity is a GameObject
- Fundamental objects in Unity that represent characters, props and scenery
- Some examples...
- Manual: 3d primitives: Cube, Cylinder, Sphere
- Camera
- Light
- Empty
- GameObjects can have multiple child GameObjects
$\Rightarrow$ they become parents - Children inherit their parent's...
- position
- rotation
- scale
- activeness
- Manual: Hierarchy: Parenting
- Manual: Transform: Parenting
-
Note: Rotating child GameObjects can have wonky results if parent has any other scale than
$(1,1,1)$ .
- Manual: Components
- GameObjects act as containers for Components that implement various functionalities
- GameObject's components and their settings are listed in the Inspector window
- Transform
- Manual: Transform
- position, rotation, scale
- parenting information
- included in every GameObject
- RigidBody
- Manual: RigidBody
- for interacting with the physics engine
- can receive forces and torque
- Collider
- Manual: BoxCollider
- enables collision with other GameObjects
- there are different shapes and sizes
- CapsuleCollider(2D), BoxCollider(2D), PolygonCollider2D...
isTrigger
- ✅ -> Collider is ignored by the physics engine, but can trigger events
- MeshFilter
- The mesh, or the 3d geometry of a GameObject
- Renderer
- Manual: MeshRenderer
- The component for drawing the GameObject on screen
- MeshRenderer, SpriteRenderer, LineRenderer, TrailRenderer...
- Material
- Manual: Material Inspector Reference
- MeshFilter only defines the geometry, but the Material component defines color and other properties
- Script
- Manual: Scripting
- The most versatile component
- For inserting custom C# code into the GameObject
- We'll dive deeper into this in 4. Scripting GameObjects