GameObjects and Components
Last updated
Last updated
The GameObject is the most basic concept in the Force. Because everything you see in you game is eventually a GameObject.
GameObjects are the everything in Force. But in fact, objects are nothing more than just containers for various components. And it is these components that make the object unique and give it functionality.
For example, to make an object a square, circle, cube (in the future) or add music or make it functional, you need to add the necessary components to it. It is the components that will determine the behavior of the object or extend it as you need. Depending on what type of object you want to create, you will need to use a certain set of components for this.
The simplest object that can be created in Force is a Square or a sprite in another way. All it has is a Sprite Renderer Component, which draws a square as a sprite and allows you to change its color or add texture.
A GameObject always has a Transform component attached (to represent position and orientation) and it is not possible to remove this. The other components that give the object its functionality can be added from the editor’s Components Menu or from a script.
Transform contains transformation (translation, scale) and orientation (rotation) of GameObject. A GameObject will always have a Transform Component attached - it is not possible to remove a Transform or to create a GameObject without one.
Transform Component have a translation, rotation and scale of GameObject.
Transformations can be changed on all 3 axes (X, Y, Z) by moving the corresponding axes or on 2 (X, Y) axes if it is 2D. A Transform can be edited in the Scene View or by changing its properties in the Inspector.
When you edit a transformation in the editor, you can switch between the following tools: moving, rotating and scaling.
To switch tools, you can use the keys: T (Translate), R (Rotate), E (Scale). Or you can click on the buttons in the scene view toolbar.
There are also existing another tool of transformation is Rect Tool.
This tool allows to modify object from each of it bound vertices, very usefully when need set specific scale of GameObject.
And final tool that Force has is Universal Tool.
Basically is a combination of three main tools: Translate, Rotate and Scale. It allows to modify this three types of transformation using one tool.
Component is a container/structure of data for GameObject. Components basically need to define behavior of any GameObject. Components contain properties which you can edit to define the behavior of a GameObject.
To view a list of the components attached to a GameObject in the Inspector, select your GameObject in either the Hierarchy or the Menu Bar.
You can add bunch of components to your GameObject. The first way to add component is using fast Component Menu in the Menu Bar. For example you can add Rigidbody component by selecting GameObject and clicking on Component -> Rigidbody2D. After this component appears in Inspector.
You can also add components throw Inspector component menu. To open the Components Menu, click on Add Component button in the Inspector.
You can attach any number or combination of components to a single GameObject. Some components work best in combination with others. For example in Force for now only, the Rigidbody2D works with a Collider2D. In future many components will depends on another components.
When you build your game you modify so many different things. One of it its changing and editing components and its values.
In Force you can change values of special component and attach asset. For example its can be Script or Image. When changing simple variable, you can input different number or click on check box, or changing the input text. When attaching items to component that request it you need to select this asset in Browser and Drag & Drop it on this item in component.
How we can see on this image below, simple variables everywhere in components. And items to, on AudioClip, on Texture and soon.
To remove component from GameObject, click on Settings -> Remove Component.
Command | Description |
Copy Component | Copies the component with all parameters and allows to paste it to another component. |
Paste Component | Paste component properties to another component with the same type. |
Paste Component As New | Paste component to another component with the same type with default parameters. |
Remove Component | Remove component from selected GameObject. |
Reset | Reset component values to default values relative to component. The same as create new component. |
Move Up | Move Up the component in Inspector. |
Move Down | Move Down the component in Inspector. |
(Transform): Show Z Axis | Shows/hide the Z axis for Transform component. |
(Script): Display File | Displays the script file in Inspector. |
(Script): Display Fields | Displays the script fields and allow to modify it. |
(Script): Executable | Mark that script will execute or not. |
Component Properties Menu
By right-clicking on component icon, another popup shows with component properties commands. Show here you can safe information about component property.
In addition to removing the component, you can also use many useful commands using the component settings. They are always displayed and are located in the right corner of each component.