Vehicle Damage Controller
Last updated
Last updated
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.
VehicleDamageController requires CollisionHandler and MeshFilter to apply deformation to the mesh.
Currently it only works on a single mesh filter, so it must be the whole body of the vehicle.
Deformation Persists is a boolean that makes the deformation stay in memory, so it is saved between scenes.
Expand the "Properties" foldout.
At this point, the standard setup for the basic vehicle deformation is complete.
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.
After you've created the CollisionAreasDataSO, assign it to the VehicleDamageController.
Two booleans will appear.
Optionally, you can assign the "PartDamageHandler" and "AttachmentsAligner" components. These components don't work by themselves and require to be assigned to the "VehicleDamageController".
Property | Description |
---|---|
Property | Desctiption |
---|---|
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.
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.