Part Damage Handler
Last updated
Last updated
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.
Give this part a name for easier identification in the list
Assign a Transform with the actual part (for example, the transform with the Spoiler mesh)
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.
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".
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.
(Optionally) Set up the dangling effect
Return to the Pivot Points array and set the "Max Rotation" values to your liking.
(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.
(Optionally) Subscribe to events
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)