Unity 3D Player Controller and Mouse Look
Unity Basics
Your First Look at Unity
Unity is a game engine, which is a powerful toolkit for creating games. It handles the complex stuff like physics, rendering 3D graphics, and playing audio, so you can focus on making your game fun. Before you can build anything, you'll need to get comfortable with the main workspace: the Unity Editor.
You'll manage your projects through the Unity Hub. Think of it as a launcher for all your different game ideas. When you're ready to start, you'll create a new project from there.
For our purposes, we'll start with a 3D template. Unity will set up a basic environment, and after a moment, the Editor will open, presenting you with a powerful, but potentially intimidating, interface.
The Core Windows
The Editor is organized into several windows, or panels. Let's break down the most important ones. Understanding how they work together is the key to mastering Unity.
Here’s a quick rundown of each window's job:
-
Hierarchy: A list of everything in your current level, or "Scene." This includes your characters, the environment, lights, and cameras. If your game is a play, the Hierarchy is the cast list.
-
Scene View: Your interactive workspace. This is where you build your world. You can fly around, place objects, and arrange everything exactly how you want it. It's the director's view of the stage.
-
Game View: This shows you what the player will see through the game's camera. You can't move objects here, but you can test your game by hitting the play button. This is the audience's view.
-
Inspector: When you select an object in the Hierarchy or Scene, its properties appear here. This is where you tweak everything about an object, from its color and size to its behavior. It's the costume and script department, all in one.
-
Project: This panel contains all the assets for your entire game, not just the current scene. Models, textures, sounds, and scripts live here. Think of it as your backstage warehouse, holding all the props you might ever need.
GameObjects and Components
In Unity, every single thing in your game world is a GameObject. The player, a tree, a light source, even an invisible boundary—they are all GameObjects.
A fresh GameObject is like a blank container. It doesn't do anything on its own. It has a name and a Transform, which just defines its position, rotation, and scale in the world. That's it.
GameObjects are the nouns of your game. Components are the verbs and adjectives that give them life.
To make a GameObject do something or look like something, you add Components. A component is a piece of functionality that attaches to a GameObject. You can mix and match components to create complex behaviors. For example, to make a simple cube, your GameObject would need:
- A Transform Component (it has this by default).
- A Mesh Filter Component to define its shape (a cube).
- A Mesh Renderer Component to make that shape visible.
- A Box Collider Component to give it a physical boundary so other objects can't pass through it.
By adding a Rigidbody component, you can instantly give that cube mass and make it react to gravity and other forces. All of this is done in the Inspector window, without writing a single line of code.
| Component | Purpose |
|---|---|
| Transform | Position, rotation, and scale. Every GameObject has one. |
| Mesh Renderer | Renders a 3D mesh, making the object visible. |
| Collider | Defines a physical shape for collisions. Comes in many forms (Box, Sphere, etc.). |
| Rigidbody | Allows a GameObject to be controlled by Unity's physics engine. |
| Audio Source | Allows the GameObject to play sounds. |
| Script | A custom component you create with code to define unique behaviors. |
This modular system of GameObjects and Components is the core concept of building things in Unity. You start with empty containers and add the pieces of functionality you need.
Which window in the Unity Editor provides an interactive, 'director's view' for building and arranging your game world?
If you select a GameObject and want to modify its properties, such as its position, color, or attached scripts, which window would you use?
Take a moment to familiarize yourself with these panels and concepts. Clicking around and exploring is the best way to learn. In the next section, we'll start putting these pieces together to build our character.
