Share on facebook
Share on twitter
Share on google

The asset comes with a damage system that is easy to extend and integrate into your project. 

Disclaimer: This chapter requires intermediate Unity and basic programming knowledge.

This component does damage to all IDamageable that qualifies for its condition. These are based on the mode and the duration of the damage source. 

Damage Source requires a helper component on the same game object based on its mode.

Mode Component Once Continuous
Particle System

Tick Cooldown (only in Continuous mode): seconds between the source could deal damage again.

Damage: This is a Damage Result object. The source will forward this to the IDamageable component(s).

As a default, this class contains only a single damage parameter. You can easily extend it to support your idea better.

When the damage happens, a Damage Source will forward this result to the IDamageable where you can take care of every parameter in the result object.

The damage source will use this interface to do damage. Here is a simple implementation of this interface. ​
public class ExampleDamageable : MonoBehaviour, IDamageable
    public int Health = 100;

    public void TakeDamage(DamageResult result)
        Health -= result.damage;
        if (Health <= 0)
            // Do something on death