Пример #1
0
    void OnTriggerStay2D(Collider2D other)
    {
        RubiController controller = other.GetComponent <RubiController>();

        if (controller != null)
        {
            controller.ChangeHealth(-1);
        }
    }
Пример #2
0
    void OnCollisionEnter2D(Collision2D other)
    {
        RubiController player = other.gameObject.GetComponent <RubiController>();

        if (player != null)
        {
            player.ChangeHealth(-1);
        }
    }
Пример #3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        RubiController controller = other.GetComponent <RubiController>();

        if (controller != null)
        {
            if (controller.Health < controller.maxHealth)
            {
                controller.ChangeHealth(1);
                Destroy(gameObject);

                controller.PlaySound(collectedClip);
            }
        }
    }