Custom Vehicle Controller
  • Custom Vehicle Controller
  • Guides
    • Workflow
      • Quick Setup
      • Creating New Parts
      • Modifying Parts
      • Creating Vehicle Parts Presets
      • Customizable Sets and Runtime Parts Change
      • Engine Performance Customization
      • Exposing Current Car Stats
    • API
      • CustomVehicleController
      • VehicleEngineSoundManager
      • RaceManager
      • RacerProgress
      • RaceSpawner
      • CollisionHandler
    • Vehicle Controller Input Provider
      • Input System Example
      • Mobile Input
    • Tips, Warnings and Requiremens
      • Work With Editor
      • Vehicle Set Up
    • AI Setup
      • AI Racer Creation
      • AI Racer Setup
      • AI Chaser Setup
      • Race Creation
      • Race Configuration
      • Race Information
    • Vehicle Damage System
      • Vehicle Damage Controller
      • Collision Area Partitioner
      • Part Damage Handler
      • Vehicle Attachments Aligner
      • Collision Handler
    • Additional Settings
      • Custom Vehicle Controller
      • Car Visuals Essentials
    • Package Settings
      • Assets Save Location
      • Project-Wide Surface Settings
    • Extra
      • Adding Visual Effects
        • Individual Effect Set Up
      • Adding Sound Effects
        • Adding Engine Sound
        • Adding Extra Sound Effects
  • Converting To Other Render Pipelines
    • Convert To Built-in RenderPipeline
    • Convert To HDRP RenderPipeline
Powered by GitBook
On this page
  • 1. Add the component and populate necessary object fields.
  • 2. Adjust the properties
  • 3. Optional optimizations
  • 4. Vehicle Part Damage
  1. Guides
  2. Vehicle Damage System

Vehicle Damage Controller

PreviousVehicle Damage SystemNextCollision Area Partitioner

Last updated 6 months ago

Vehicle Damage Controller is responsible for mesh deformation and controls other damage system related scripts, like PartDamageHandler and VehicleAttachmentsAligner.

Mathematics and Burst packages must be installed, otherwise the script will not be available at all.

You must enable the read/write property in the import settings on mesh to enable mesh deformation.

1. Add the component and populate necessary object fields.

VehicleDamageController requires CollisionHandler and MeshFilter to apply deformation to the mesh.

2. Adjust the properties

Deformation Persists is a boolean that makes the deformation stay in memory, so it is saved between scenes.

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. 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" and "AttachmentsAligner" components. These components don't work by themselves and require to be assigned to the "VehicleDamageController".