コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (healthandDamage.death == false)
     {
         healthandDamage.curhealth = healthandDamage.curhealth - healthandDamage.damage * Time.deltaTime;
     }
     healthandDamage.MinMaxValue();
     healthandDamage.ratio                     = healthandDamage.curhealth / healthandDamage.maxHealth;
     healthandDamage.curhealthRounded          = Mathf.Round(healthandDamage.curhealth);
     healthandDamage.healthText.text           = healthandDamage.curhealthRounded.ToString() + "%";
     healthandDamage.healthbarScale.localScale = new Vector3(healthandDamage.ratio, healthandDamage.healthbarScale.localScale.y, healthandDamage.healthbarScale.localScale.z);
 }
コード例 #2
0
 void OnTriggerStay(Collider other)
 {
     if (healthandDamage.death == false)
     {
         if (other.gameObject.tag == "Player")
         {
             healthandDamage.curhealth = healthandDamage.curhealth - healthandDamage.damage * Time.deltaTime;
             healthandDamage.MinMaxValue();
             healthandDamage.ratio                     = healthandDamage.curhealth / healthandDamage.maxHealth;
             healthandDamage.curhealthRounded          = Mathf.Round(healthandDamage.curhealth);
             healthandDamage.healthText.text           = healthandDamage.curhealthRounded.ToString() + "%";
             healthandDamage.healthbarScale.localScale = new Vector3(healthandDamage.ratio, healthandDamage.healthbarScale.localScale.y, healthandDamage.healthbarScale.localScale.z);
         }
     }
 }