# Trailer Setup

### 1. Add necessary components

A trailer is simulated with a TrailerController component. Simply add this component to the ROOT game object of the trailer.&#x20;

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FYRa1pa3U3tbuqOayNOkz%2Fimage.png?alt=media&#x26;token=97807b05-d47a-40a1-9c2b-8ab4466c1874" alt=""><figcaption></figcaption></figure>

Two other required components will be added automatically: TrailerVisualsEssentials and TrailerConnector. (as well as a Rigidbody and a Joint). The references should be automatically injected as well.

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FMp5u4vLtezYTdzDiOpSz%2Fimage.png?alt=media&#x26;token=62260e48-53c1-4399-9584-ed861b14f351" alt=""><figcaption></figcaption></figure>

TrailerVisualsEssentials functions similarly to [CarVisualsEssentials](https://distubredone322.gitbook.io/custom-vehicle-controller/guides/additional-settings/car-visuals-essentials).&#x20;

[TrailerConnector ](https://distubredone322.gitbook.io/custom-vehicle-controller/guides/trailer-system/trailerconnector)is an essential component for actually connecting a trailer to the truck.

### 2. Create vehicle axles

Similarly to CustomVehicleController, TrailerController uses VehicleAxle array. The only difference is that it does not differentiate between front and rear axles.

To add new axles, open a "VehicleAxleWindow".

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2F6N3S7ChBmcm8EPV8Wx82%2Fimage.png?alt=media&#x26;token=c3d46d1c-9a9e-4062-957f-ac42ce0d9cae" alt=""><figcaption></figcaption></figure>

An editor window should open. Next, make sure the trailer controller game object is selected.&#x20;

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FXlnjxqljK1D3MXA1CBSn%2Fimage.png?alt=media&#x26;token=3edf28bf-376b-40e7-8924-9cf857a1eb56" alt=""><figcaption></figcaption></figure>

The window will bind to it.

{% hint style="info" %}
You can lock the window in the bottom left to stop rebinding the window after selecting/deselecting game objects.
{% endhint %}

Click on "Add" to add as many possible axles as you want.&#x20;

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2Fni3wfAeh8YjUhNYDYTHE%2Fimage.png?alt=media&#x26;token=18a17dbf-db78-44b5-bb33-b8a485ba36f2" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Similarly to the initialization of the CustomVehicleController, Brakes Transforms fields are optional. However, only axles that have both Left and Right Wheel Transforms references will count as valid.&#x20;
{% endhint %}

Drag and drop the wheel references into their respective fields in the editor window

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FlpSlrUa6KTBuocwF5au0%2Fimage.png?alt=media&#x26;token=acdb682c-0857-4a19-b1a4-a53f1c6538a7" alt=""><figcaption></figcaption></figure>

Next, click on the "Add Axles" button.

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FKVFE0XAWEdbaCbyRZJGD%2Fimage.png?alt=media&#x26;token=851cf348-d488-4d71-9c0e-8b7cb9374e8d" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
If the selected game object is a prefab, you'll need to unpack it. If you try to initialize the controller on the prefab, a warning will be shown:&#x20;

![](https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FKnHHaqXLwncdjgCtTyGn%2Fimage.png?alt=media\&token=878d7932-1c60-4d6e-8a11-328edd1d1eb3)

After clicking "Yes", the prefab will be unpacked completely and the controller will be initialized. You won't be able to initialize the controller as long as the selected game object is a prefab.
{% endhint %}

The trailer controller is initialized now.

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2F3YyN7ZF7ONetCGKkIEv5%2Fimage.png?alt=media&#x26;token=8f14f067-5394-4613-9108-7dc221e7c802" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FQVVaBbLMXEeMi4M3QkCE%2Fimage.png?alt=media&#x26;token=4ecf15b8-b03a-4940-be2e-e27120ef7d9d" alt=""><figcaption></figcaption></figure>

### 3. Assign parts to the trailer

Similarly to the CustomVehicleController, a TrailerController can use a customizable set of parts or a parts preset. The difference is that a trailer only uses "chasis" parts like body, wheels, suspension and brakes.

Set "UsePreset" to True and select a preset from the object find window.

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2F0cjACw9krO7VGlLD5Q1O%2Fimage.png?alt=media&#x26;token=026f2aa2-7e3a-4ce9-b059-6a24f5b89c74" alt=""><figcaption></figcaption></figure>

Next, adjust the  TrailerConnector

{% content-ref url="trailerconnector" %}
[trailerconnector](https://distubredone322.gitbook.io/custom-vehicle-controller/guides/trailer-system/trailerconnector)
{% endcontent-ref %}

### 4. Creating/modifying/changing parts and presets.

Similarly to CustomVehicleControler, TrailerController has its own editor window where you can create/change/modify parts and presets.

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FuooP95ItQLZhIJbWctla%2Fimage.png?alt=media&#x26;token=087c5433-e6e8-4aac-bffa-be276bb93221" alt=""><figcaption></figcaption></figure>

The workflow is absolutely the same to the editor for CustomVehicleController.

<figure><img src="https://3780384024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPyvySfaC85jUgVcDPRJ%2Fuploads%2FiTa0aE0aVWpSXmhwNUvd%2Fimage.png?alt=media&#x26;token=a8bebbc8-b266-4c96-8c82-a9cdc3663d7a" alt=""><figcaption></figcaption></figure>

{% content-ref url="../workflow/creating-new-parts" %}
[creating-new-parts](https://distubredone322.gitbook.io/custom-vehicle-controller/guides/workflow/creating-new-parts)
{% endcontent-ref %}

{% content-ref url="../workflow/modifying-parts" %}
[modifying-parts](https://distubredone322.gitbook.io/custom-vehicle-controller/guides/workflow/modifying-parts)
{% endcontent-ref %}
