Exemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        ObjectLifeSystem comp = collision.gameObject.GetComponent <ObjectLifeSystem>();

        comp.Damage(Damage);
        Destroy(this.gameObject);
    }
Exemplo n.º 2
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        bool isEnemy = collision.gameObject.tag == "Enemy";
        bool isNest  = collision.gameObject.tag == "Nest";

        if (!isEnemy && !isNest)
        {
            ObjectLifeSystem comp = collision.gameObject.GetComponent <ObjectLifeSystem>();
            comp.Damage(Damage);
        }
    }