A game made with Unity consists of a collection of game objects that the developer has made to work together by writing scripts for them. In addition to the scripts, components provided by the game engine have been added to the objects, which handle the physics and collisions of the object, among other things. Coding a game can be as easy as hiding and unhiding game objects, activating and deactivating components, or changing their values. The development process is pretty similar whether it's a three-dimensional or two-dimensional game.
A Game Made with Unity
Scene
A Unity game consists of scenes in which the player can move from one to the other. The first scene is most often the main menu of the game. The next scene can be the main area of the game world where the player spends most of their time. If there are, for example, caves or building interiors in the game each of them can have its own scene.
In addition to the game world made out of game objects, a scene also includes in-game menus, such as a pause menu.
Game Object
A game object is an invisible item added to the scene that itself does nothing. As mentioned earlier, components are added to the object that together makes the object an essential part of the game. The object acts as a container of components, so to speak.
The game consists of objects visible and invisible to the player. Visible game objects include characters, lights, and the environment. Examples of invisible objects include triggers, cameras, and waypoints of a patrolling enemy’s route.
Component
Unity has several built-in components. There are two different versions of many of them, a version for two-dimensional and three-dimensional games.
When, for example, a light source component is added to a game object it illuminates its surroundings. When an effect component is added to the object, it makes the object emit images or 3D models.
So it can be said that the game engine does a great deal on behalf of the developer. However, the logic of the game itself is left to the developer. Logic is created by writing scripts and placing them on objects as components.
Script
Game programming can seem difficult at first. In reality, it’s not as long as you learn the basics of the programming language.
One of the most essential parts of Unity game programming is manipulating components from code. In Unity, developers use the C# programming language to write scripts.
Building the Game
When the game is ready or when the developer wants to get feedback from external game testers, the game must be built as a program that can be run outside the game engine. The game files can be sent to testers as is but they can also be published on video game distribution services.
Unity makes it possible to build the game on multiple platforms. These include:
- Windows
- Mac
- Linux
- Android
- iOS
- PlayStation
- Xbox
- Nintendo Switch
- web browsers
With Unity, it’s also possible to make VR and AR games, taking advantage of virtual reality and augmented reality.
Unity Hub
To start developing games with Unity, you need a program called Unity Hub. This is a program that manages the versions and game projects of the Unity game engine installed on your computer.
Downloading
Let’s get started by downloading Unity Hub. Type Unity in the search field and go to the download page.
Click the Download button.
Installing
Open the downloaded installation file and go through the program installation, accepting all the terms.
Click the Install button to install the recommended version of the game engine.
This process will take some time. Once the installation has finished, go to the Projects tab.
Creating a Project
To create a new project, click the New Project button. At this point, you need to select a template for the project. Open the Core tab and select the 3D option.
It’s recommended that you give the project a descriptive name, as this name will appear in the Unity Hub project listing. If you want, you can change the file location of the project. Click the Create button to create the project.
Unity’s User Interace
Scene
This is the user interface of Unity. In the middle of the interface is the Scene window from which you can view and edit the game world.
To move around the game world, hover your mouse over the Scene window and hold down the right mouse button. Moving the mouse rotates the view according to the movement.
While holding down the right mouse button you can press the W, A, S, and D keys to move in the world.
The E and Q keys raise and lower the view.
By default, there are two game objects in the game world, a camera, and a light source. Every object in the game world is listed in the game world’s hierarchy.
Hierarchy
The hierarchy is located on the left side of the interface in the Hierarchy window. It presents the objects of the game world in a hierarchical text format and expresses the structure of the objects in the world.
To manipulate an object, select it by left-clicking it in either the Hierarchy or Scene window. The selected objects appear highlighted in the hierarchy. The scene window displays an object differently depending on its type.
Toolbar
Above the Hierarchy and Scene window is a toolbar. It includes functions for manipulating objects, such as moving, rotating, and resizing.
Game
The game can be started with the Play button in the middle of the toolbar. When the game starts, Unity automatically activates the Game window on the second tab, which opens in place of the Scene window.
The view of the Game window is what the player sees while playing your game. Camera objects are used to control what the player sees.
The Game view cannot be moved in the same way as the Scene view, nor can the world be modified from it. You can still make changes to the world when the game is running but when you stop the game the changes will not be saved. To stop the game click the Play button again.
Inspector
On the right side of the interface is the Inspector window, which lists information about the selected object, such as its components.
By default, a camera object has three components: Transform, Camera, and Audio Listener.
The default components of the light source object are Transform and Light.
The components of an object determine how the object behaves in the game world.
Project
At the bottom of the interface is a window called Project. It contains two folders: Packages and Assets.
The Packages folder contains Unity’s internal resources that the project uses. The Assets folder contains your personal files, such as 3D models, scripts, images, and sounds.
Console
The Console window on the second tab notifies you of errors, warnings, and other information regarding your project.