Practical Game Design with Unity and Playmaker — Save 50%
Leverage the power of Unity 3D and Playmaker to develop a game from scratch with this book and ebook
Unity works using a popular and common approach for game development, which is called the component-based architecture. This approach is widely used in software development to make things more reusable and easier to manage.
Let us talk about the way things are organized in Unity in this article by Sergey Mohov, the author of Practical Game Design with Unity and Playmaker.
(For more resources related to this topic, see here.)
First of all, you have a project, which is essentially a folder that contains all of the files and information about your game. Some of the files are called scenes (think of them as levels). A scene contains a number of game objects that you have added to it. The contents of your scenes are determined by you, and you can have as many of them as you want. You can also make your game switch between different scenes, thus making different sets of game objects active.
On a smaller scale, you have game objects and components. A game object by itself is simply an invisible container that does not do anything. Without adding appropriate components to it, it cannot, for instance, appear in the scene, receive input from the player, or move and interact with other objects. Using components, you can easily assemble powerful game objects while reusing several small parts, each responsible for a simple task or behavior—rendering the game object, handling the input, taking damage, playing an audio effect, and so on—making your game much simpler to develop and manage. Unity relies heavily on this approach, so the better you grasp it, the faster you will get good at it.
The only component that each and every game object in Unity has attached to it by default is Transform. It lets you define the game object's position, rotation, and scale. Normally, you can attach, detach, and destroy components in any given game object at will, but you cannot remove Transform.
Each component has a number of properties that you can access and change: these can be integer or floating point numbers, strings of text, textures, scripts, references to game objects or other components. They are used to change the way a certain component behaves, to influence its appearance or interaction. Some of the properties include the position, rotation, and scale properties of the Transform component.
The following screenshot shows the Wall game object with the Transform, Mesh Filter, Box Collider, Mesh Renderer, and Script components attached to it. the properties of Transform are displayed. In order to reveal or hide a component's properties you need to left-click on its name or on the small arrow on the left of its icon.
Unity has a number of predefined game objects that already have components attached to them, such as cameras, lights, and primitives. You can access them by choosing GameObject | Create from the main menu. Alternatively, you can create empty game objects by pressing command + Shift + N (Ctrl + Shift + N in Windows) and attach components to them using the Components submenu.
The following figure shows the project structure that we have discussed. Note that there can be any number of scenes within a single project, any number of game objects within a single scene, any number of components attached to a single game object, and finally, any number of properties within a single component.
One final thing that you need to know about components right now is that you can copy them by right-clicking on the name of the component in the Inspector panel and selecting Copy Component from the contextual menu shown in the following screenshot. You can also reset the properties of the components to their default values, remove components, and move them up or down for your convenience.
This article has covered the basic concept of the component-based approach of Unity and the figures/screenshots demonstrate the various aspect of the same.
Resources for Article:
- Mobile Game Design [Article]
- Unity Game Development: Welcome to the 3D world [Article]
- Interface Designing for Games in iOS [Article]
|Leverage the power of Unity 3D and Playmaker to develop a game from scratch with this book and ebook|
eBook Price: $17.99
Book Price: $29.99
About the Author :
Sergey Mohov is a game developer and designer with over three years of experience in working on games in Unity. His prominent projects include Dédale, Paradis Perdus, and Lune. The rest of Sergey's games can be found on his website at http://sergeymohov.com along with his personal blog.