> For the complete documentation index, see [llms.txt](https://danil-dukhovenko.gitbook.io/force/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://danil-dukhovenko.gitbook.io/force/force-editor/gameplay/gameobjects-and-components.md).

# GameObjects and Components

### GameObjects and Components

The **GameObject** is the most basic concept in the Force. Because everything you see in you game is eventually a GameObject.

<div align="left"><img src="https://user-images.githubusercontent.com/56895345/172505254-1f5ee8fe-b822-44f0-924d-e2cd45563d7b.png" alt="Game objects"></div>

**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.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FPKcDn4EfsZmTcgBiiLw4%2Fimage.png?alt=media&amp;token=635b8241-ae4d-4828-8a0c-1c1e8d03b55e" alt=""><figcaption><p>Game object Components in Inspector</p></figcaption></figure></div>

#### Note

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

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.

#### The Transform Component

Transform Component have a **translation**, **rotation** and **scale** of **GameObject**.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FtIBtYi57J1Z4hB9wcIgE%2Fimage.png?alt=media&amp;token=fc1a6654-d566-4712-ac68-2353d0b2d49e" alt=""><figcaption><p>The Transform Component details</p></figcaption></figure></div>

#### Editing Transform

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**.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FS0b2Ls4GmcEzZ9LqDDs2%2Fimage.png?alt=media&amp;token=816dd434-0dab-4ed8-a605-f3f21e276d0a" alt=""><figcaption><p>Translate Gizmos</p></figcaption></figure></div>

When you edit a transformation in the editor, you can switch between the following tools: moving, rotating and scaling.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2F0TZSCPkhvYgtd5gW38ww%2Fimage.png?alt=media&amp;token=fded3a30-97bb-4a54-bf7a-17f634984b20" alt=""><figcaption><p>Editing Tools</p></figcaption></figure></div>

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.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FZWqzQrMb7yOC6MF06m2N%2Fimage.png?alt=media&amp;token=5ea04bcc-aa3f-4f39-b1fd-45a1a11fb41f" alt=""><figcaption><p>Type of Tool</p></figcaption></figure></div>

There are also existing another tool of transformation is **Rect Tool**.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FV8DUINpXoVwcwHE7kkWa%2Fimage.png?alt=media&amp;token=93974d50-ad06-4690-96af-63b30646c0c3" alt=""><figcaption><p>Rect Tool</p></figcaption></figure></div>

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**.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FcwokH6XnZ3IWykqp3NLS%2Fimage.png?alt=media&amp;token=419881c8-b204-47ae-93b9-8f16aec077a0" alt=""><figcaption><p>Universal Tool</p></figcaption></figure></div>

Basically is a combination of three main tools: **Translate**, **Rotate** and **Scale**. It allows to modify this three types of transformation using one tool.

### Using Components

**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**.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FbUubWuRYjLQr6ucphxv6%2Fimage.png?alt=media&amp;token=00d111d9-18c4-4d08-81fc-c08f8b03ad64" alt=""><figcaption><p>Components Menu</p></figcaption></figure></div>

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2F6PDefb2eSkZFb7RIRYgT%2Fimage.png?alt=media&amp;token=9ddbf295-f1a7-4e8b-aca2-9bcf781d2da8" alt=""><figcaption><p>Components Menu in Menu Bar</p></figcaption></figure></div>

#### Add Components

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.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FZTm6uCoLZZtow4SUiUdS%2Fimage.png?alt=media&amp;token=0465e975-9155-45d8-b539-6ab5710c1732" alt=""><figcaption><p>Clicking on Components Menu</p></figcaption></figure></div>

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FaIcGIlxwQAtjUzSHxwEi%2Fimage.png?alt=media&amp;token=eaada4fb-e379-462c-a285-7cc220a0a4fa" alt=""><figcaption><p>Add Component in Components Menu</p></figcaption></figure></div>

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.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FOyaW5yG2rOhL9lBRdRdG%2Fimage.png?alt=media&amp;token=25227378-b3cf-47a7-b63b-28cc898f1f93" alt=""><figcaption><p>New Rigidbody2D component added to GameObject</p></figcaption></figure></div>

#### Edit 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.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2Ff1z8r7iSjspNhynVTEAk%2Fimage.png?alt=media&amp;token=3df86827-5283-45d7-bfce-957649a79c88" alt=""><figcaption><p>Variation of components in Inspector</p></figcaption></figure></div>

#### Removing Components

To remove component from GameObject, click on **Settings** -> **Remove Component**.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FljEoEVQJQ1M7M0Agm5BJ%2Fimage.png?alt=media&amp;token=71f8523d-1240-4670-be70-3c21dfb8ef5c" alt=""><figcaption><p>Removing Component</p></figcaption></figure></div>

#### Component Settings

In addition to removing the component, you can also use many useful commands using the component settings. They are always displayed ![](https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FuEt5CvX67U3gDKZr9SLM%2Fimage.png?alt=media\&token=e2469e6d-29db-42a0-b323-04ad4ddba3d7) and are located in the right corner of each 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**

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2Fph9t9Xkumklxs0xY963j%2Fimage.png?alt=media&amp;token=9a609724-c0ba-480d-bd81-680d6d817f3e" alt=""><figcaption><p>Component Properties Menu</p></figcaption></figure></div>

By right-clicking on component icon, another popup shows with component properties commands. Show here you can safe information about component property.
