// Update is called once per frame void Update() { float width = Mathf.Max( 0, healthToWatch.getHealth() * maxSize / healthToWatch.getMaxHealth() ); Vector2 newSize = new Vector2(width, transform.localScale.y); transform.localScale = newSize; }
void updateWidth() { float healthRatio = actorHealth.getHealth() / (float)actorHealth.getMaxHealth(); transform.localScale = new Vector2(healthRatio, transform.localScale.y); }