//damages the instace
 public void damage(float taken)
 {
     health -= taken;
     ASound.playDamageSound();
     if (health <= 0f)
     {
         death();
     }
     wasDamaged       = true;
     timeToStopDamage = 0.5f;
     overlay.SetActive(true);
     seenPlayer = true;
 }
    //damages player
    public void damage(float damage)
    {
        //reduces health and healthbar
        health -= damage;
        healthBar.GetComponent <Slider> ().value = health;

        //plays sound
        ASound.playDamageSound();

        //checks if dead
        if (health <= 0 && canMove)
        {
            death();
        }
    }