Do am I weirdo? 🤭

I’ve made it different, but looks more easy to me that way, is it more resources costly that way?

private void Update()
        {
            if (healthComponent.GetHealthPoint() < healthComponent.GetMaxHealthPoints())
                canvas.gameObject.SetActive(true);

            forground.localScale = new Vector3(healthComponent.GetFraction(), 1, 1);
            
            if (healthComponent.IsDead())
                D

No real difference in resource cost than what we’re already doing.
Ideally, you’re going to want to convert this to the Observer Pattern, where the UI only updates when the health changes. This will be introduced in later lectures, although we don’t directly update the Healthbar code.

1 Like

Got it. :+1:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms