> For the complete documentation index, see [llms.txt](https://distubredone322.gitbook.io/custom-vehicle-controller/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://distubredone322.gitbook.io/custom-vehicle-controller/guides/vehicle-damage-system/vehicle-damage-controller.md).

# Vehicle Damage Controller

Vehicle Damage Controller is responsible for mesh deformation and controls other damage system related scripts, like [PartDamageHandler ](/custom-vehicle-controller/guides/vehicle-damage-system/part-damage-handler.md)and [VehicleAttachmentsAligner](/custom-vehicle-controller/guides/vehicle-damage-system/vehicle-attachments-aligner.md).

{% hint style="warning" %}
Mathematics and Burst packages must be installed, otherwise the script will not be available at all.

![](/files/ktboLgxX2GEXb9JnDUzb)![](/files/Yfglxx6CDKKcIcY0YXrQ)
{% endhint %}

{% hint style="info" %}
You must enable the read/write property in the import settings on mesh to enable mesh deformation.

![](/files/Z1FfAYf2hPZ067tLTan0)
{% endhint %}

### 1. Add the component and populate necessary object fields.

VehicleDamageController requires [CollisionHandler](/custom-vehicle-controller/guides/vehicle-damage-system/collision-handler.md) and MeshFilter to apply deformation to the mesh.&#x20;

<figure><img src="/files/6P0f8VvOUyZ4CAoUCz0c" alt="" width="509"><figcaption></figcaption></figure>

### 2. Adjust the properties

{% hint style="info" %}
Deformation Persists is a boolean that makes the deformation stay in memory, so it is saved between scenes.
{% endhint %}

Expand the "Properties" foldout.

| Property                      | Description                                                                                                                                                                                                                                       |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Main Mesh Filter              | The mesh of the vehicle's body.                                                                                                                                                                                                                   |
| Additional Mesh Filters Array | The meshes of other vehicle body parts that will take part in deformation. For example, bumpers and doors, if those have separate meshes                                                                                                          |
| Body Strength                 | Defines how resilient the vehicle is to deformation. \[0.001 - 0.999], where 0.999 makes the vehicle suffer almost no damage.                                                                                                                     |
| Damage Radius Multiplier      | When a collision occurs, the CollisionHandler sends the CollisionImpactInfo for every collision point. One of the properties is the distance to the previous point, which defines the area of the collision. Multiplier affects this area's size. |
| Additional Damage Radius      | Added radius to the area outside the normal damage radius. Noise is applied to the vertices outside the normal damage radius, so too big value can cause weird deformation.                                                                       |
| Max Deform Depth              | The maximum distance the vertice can be moved from the original position.                                                                                                                                                                         |

At this point, the standard setup for the basic vehicle deformation is complete.

### 3. Optional optimizations

For better performance you can split the vehicle mesh into possible collision areas, so that the amount of work when collision occurs will be lowered. Learn how to create CollisionAreasDataSO [here](/custom-vehicle-controller/guides/vehicle-damage-system/collision-area-partitioner.md). Note that as of version 3.3.0, this works only for a single mesh deformation.

After you've created the CollisionAreasDataSO, assign it to the VehicleDamageController.

Two booleans will appear.

| Property                        | Desctiption                                                                                                                     |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Collision Areas Optimization    | Using the CollisionAreasDataSO, find the area where the collision occured and apply deformation only to the vertices inside it. |
| Deform Affected Collision Areas | Find all the other areas that are inside the resulting collision damage radius and apply deformation to them as well.           |

### 4. Vehicle Part Damage

Optionally, you can assign the "[PartDamageHandler](/custom-vehicle-controller/guides/vehicle-damage-system/part-damage-handler.md)" and "[AttachmentsAligner](/custom-vehicle-controller/guides/vehicle-damage-system/vehicle-attachments-aligner.md)" components. These components don't work by themselves and require to be assigned to the "VehicleDamageController".


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://distubredone322.gitbook.io/custom-vehicle-controller/guides/vehicle-damage-system/vehicle-damage-controller.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
