void Update() { float lifePercent = Mathf.InverseLerp(0, critter.getMaxLife(), critter.getLife()); Color currentColor; if (lifePercent > 0.5f) { currentColor = Color.Lerp(midColor, healtyColor, 2f * (lifePercent - .5f)); } else { currentColor = Color.Lerp(starvingColor, midColor, 2f * lifePercent); } torzo.color = currentColor; }
public int SampleLife() { return(critterCtrl.getLife()); }