Example #1
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "enemyObj")
        {
            if ((hb.healthBarTransform.localScale.x > 0.01f) && recieveDamage == true)
            {
                Destroy(collision.gameObject);
                hb.setBarSize(attackStrength);
                anim.SetTrigger("Impact");
            }

            if (hb.healthBarTransform.localScale.x <= 0.1f && recieveDamage == true)
            {
                recieveDamage = false;
                anim.SetTrigger("Death");
            }
        }

        //Drone
        if (collision.gameObject.tag == "droneObj")
        {
            if ((hb.healthBarTransform.localScale.x > 0.01f) && recieveDamage == true)
            {
                hb.setBarSize(attackStrength);
                anim.SetTrigger("Impact");
            }

            if (hb.healthBarTransform.localScale.x <= 0.1f && recieveDamage == true)
            {
                recieveDamage = false;
                anim.SetTrigger("Death");
            }
        }



        //collectibles
        if (collision.gameObject.tag == "collectibleHealth")
        {
            Debug.Log("player");
            if (hb.healthBarTransform.localScale.x < 1.0f)
            {
                hb.setBarSize(-0.2f);
            }
            collision.gameObject.SetActive(false);
        }
    }
Example #2
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.gameObject.tag == "player")
        {
            Debug.Log("player");
            hb.setBarSize(attackStrength);
        }

        //if(collision.collider.tag=="player")
        //{
        //    Debug.Log("player");
        //    hb.setBarSize(attackStrength);
        //}
    }