Exemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D other)
    {
        MoveWithInput player = other.gameObject.GetComponent <MoveWithInput>();

        if (player != null)
        {
            player.ChangeHealth(-1);
        }
    }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        MoveWithInput controller = other.GetComponent <MoveWithInput>();

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