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 assign the controller
  • 2. Reference this component to the VehicleDamageController
  • 3. Add the new Damagable Vehicle Part
  1. Guides
  2. Vehicle Damage System

Part Damage Handler

PreviousCollision Area PartitionerNextVehicle Attachments Aligner

Last updated 9 months ago

PartDamageHandler is a component responsible for keeping track of the individual part's health points, reduce health on collision and create the "danging" and "detachment" effect under certain condition.

1. Add the component and assign the controller

2. Reference this component to the VehicleDamageController

3. Add the new Damagable Vehicle Part

  1. Give this part a name for easier identification in the list

  1. Assign a Transform with the actual part (for example, the transform with the Spoiler mesh)

  1. Optionally (assign the pivot points)

Pivot points are used for the "dangling effect. The part will be parented to the furthest pivot point when the health will be depleted.

  1. Select what Transforms will be taken into calculation when deciding if the part has suffered any damage after collision

For example, if you wanted to create a damageable hood that will be dangling after collision, you would have a Pivot point near the window for the correct rotation, and the Part Transform would be in the front of the car so that the front collisions would be close enough to this Transform. In this case, you would select "Part Transform".

  1. Set the initial health points.

The "body strength" property on the VehicleDamageController affects the amount of damage the parts suffer.

You can see how much approximately collisions deal damage by enabling the "Debug" mode of the inspector. The "Damage Sustained" property will be revealed, that will show you the numbers in play mode.

  1. (Optionally) Set up the dangling effect

Property
Description

Min Speed For Dangling

The minimum speed required for effect to start growing.

Dange Max Effect Speed

The speed at which effect will be maxxed out.

Dangle Rate

The amount of back and forth rotations between the part's original rotation and the "Max Rotation" property of the Pivot Point the part was parented to (at max effect strength)

Return to the Pivot Points array and set the "Max Rotation" values to your liking.

  1. (Optionally) Set up the detachment effect

The detachment can occur when the vehicle suffered enough damage or when the vehicle has suffered enough damage and moves at high enough speed.

Select at least 1 of those conditions. If "Detach at High Speed" has been selected, "Detach Speed" property will be shown.

When detached, a Rigidbody will be added to the part. You can optionally set the flag to add BoxCollider as well.

In 5 seconds after the detachment, the part's gameObject will be set inactive.

  1. (Optionally) Subscribe to events