Example #1
0
    void OnTriggerStay2D(Collider2D other)
    {
        GG_moving ggController = other.GetComponent <GG_moving>();

        if (ggController != null)
        {
            ggController.ChangeHealth(-1);
        }
    }
Example #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        GG_moving ggController = other.GetComponent <GG_moving>();

        if (ggController != null && ggController.currentHealth < ggController.maxHealth)
        {
            ggController.ChangeHealth(1);
            Destroy(gameObject);
        }
    }