Health
The Health component goes on the root transform of a vehicle, and manages collectively all the damageables on the vehicle.
Toggle Vehicle Damage
To toggle vehicle damage in the editor, you can check/uncheck the Is Damageable checkbox in the inspector of the Health component.
To toggle it during gameplay, use the following code:
// Make vehicle un-damageable
myVehicleHealth.IsDamageable = false;
// Make vehicle damageable
myVehicleHealth.IsDamageable = true;Toggle Vehicle Healing
To toggle vehicle healing in the editor, you can check/uncheck the Is Healable checkbox in the inspector of the Health component.
To toggle it during gameplay, use the following code:
// Make vehicle un-healable
myVehicleHealth.IsHealable = false;
// Make vehicle healable
myVehicleHealth.IsHealable = true;Destroy Damageables
To destroy all the damageables on a vehicle during gameplay, use the following code:
Restore Damageables
To restore all the damageables on the vehicle, use the following code:
Vehicle Health Info
To query vehicle health information, you can use the following code:
Last updated
Was this helpful?