> For the complete documentation index, see [llms.txt](https://mindcodeinteractive.gitbook.io/easy-build-system-old/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mindcodeinteractive.gitbook.io/easy-build-system-old/components/building-placer.md).

# Building Placer

Manages all aspects of building modes (Placement, Destruction, Edition).

Include three **Build Modes**

* Placement Mode allows you to preview a [Building Part](/easy-build-system-old/components/building-part.md) to place it.
* Destruction Mode allows you to preview a [Building Part](/easy-build-system-old/components/building-part.md) already placed to destroy it.
* Edition Mode allows you to preview a [Building Part](/easy-build-system-old/components/building-part.md) already placed to move it elsewhere.

A **Input Handler** component is required to know which actions to trigger according to user inputs.

By default the system uses the **Standalone Input Handler** to handle user inputs.\
It allows you to manage the selection of build modes and of different [Building Parts](/easy-build-system-old/components/building-part.md) available in the [Building Manager](/easy-build-system-old/components/building-manager.md) of the scene. You can change the Action's key for each action directly in the inspector. This works also with the new Unity Input System.

If you want to use the system for Android platforms. You can use the **Android Input Handler.**

On platforms which require a gamepad. You can use the **Gamepad Input Handler**.\
You will need to use the new Unity Input System and import the support [here](/easy-build-system-old/getting-started/getting-started.md).

This component must be attached to a camera with the tag "Main Camera".\
In the **Raycast Settings** section, you can choose the type of view according to your game view.

**FIRST\_PERSON\_VIEW** Cast a ray from the camera to forward direction.

![Expand the image to large view by clicking on it.](https://gblobscdn.gitbook.com/assets%2F-MKOQJwyVxlWgqdlaL9V%2F-MKQr7Q5IAWWc7vnSXIb%2F-MKTEXHutfsfqhCvS1UP%2F68747470733a2f2f692e6962622e636f2f4b5648683073442f4669727374706572736f6e2d312e706e67.png?alt=media\&token=b3a6a00b-1f2d-4dae-9e15-668903f4902a)

**THIRD\_PERSON\_VIEW** Cast a ray from the character to forward direction.

![Expand the image to large view by clicking on it.](https://gblobscdn.gitbook.com/assets%2F-MKOQJwyVxlWgqdlaL9V%2F-MKQr7Q5IAWWc7vnSXIb%2F-MKTF0P5vLRBFJmuh5W0%2F68747470733a2f2f692e6962622e636f2f544c4c315474352f5468697264706572736f6e2e706e67.png?alt=media\&token=57ce3992-1f15-4fdf-a4e5-33a4bf0c00b6)

**TOP\_DOWN\_VIEW** Cast a ray from the camera to world mouse position.

![Expand the image to large view by clicking on it.](https://gblobscdn.gitbook.com/assets%2F-MKOQJwyVxlWgqdlaL9V%2F-MKQr7Q5IAWWc7vnSXIb%2F-MKTFXFx5XxyK_YKHOPP%2F68747470733a2f2f692e6962622e636f2f44774c4257336a2f546f70646f776e2e706e67.png?alt=media\&token=765fe397-4559-4786-a85f-4ef4e9e0b066)

{% hint style="info" %}
Explore fields description in the Inspector by hovering your cursor over them.\
You can find more information about this here: [Tooltip Attribute](https://docs.unity3d.com/ScriptReference/TooltipAttribute.html).
{% endhint %}

***

## API

You can access this class by including the following namespace:

```csharp
using EasyBuildSystem.Features.Runtime.Buildings.Placer;
```

This class inherits from **Singleton** class and can be called like this:

```csharp
BuildingPlacer.Instance
```

Here is a list of all the events and methods of this component that can be called:

{% tabs %}
{% tab title="Events" %}

#### Events

```csharp
/// <summary>
/// Event that is triggered when the build mode is changed.
/// </summary>
BuildingPlacer.Instance.OnChangedBuildModeEvent.AddListener((BuildMode mode) => { });

/// <summary>
/// Event that is triggered when the Building Part selection is changed.
/// </summary>
BuildingPlacer.Instance.OnChangedBuildingPartEvent.AddListener((BuildingPart part) => { });
```

{% endtab %}

{% tab title="Methods" %}

#### Methods

```csharp
/// <summary>
/// Get the target Building Part based on the closest overlap sphere hit.
/// </summary>
/// <returns>The target Building Part if found, null otherwise.</returns>
BuildingPart targetPart = BuildingPlacer.Instance.GetTargetBuildingPart();

/// <summary>
/// Rotate the current preview.
/// </summary>
/// <param name="reverse">Whether to rotate the preview in reverse direction.</param>
BuildingPlacer.Instance.RotatePreview(bool reverse);

/// <summary>
/// Select a specific Building Part.
/// </summary>
/// <param name="part">The Building Part to select.</param>
BuildingPlacer.Instance.SelectBuildingPart(BuildingPart part);

/// <summary>
/// Change the build mode.
/// </summary>
/// <param name="mode">The new build mode.</param>
/// <param name="clearPreview">Whether to clear the current preview or not.</param>
BuildingPlacer.Instance.ChangeBuildMode(BuildMode mode);
```

{% endtab %}
{% endtabs %}

All of the methods related to this component can be found in the file "BuildingPlacer.cs".\
If you have any specific questions about the API, feel free to contact us.
