using System.Collections; using System.Collections.Generic; using UnityEngine; public class HealthBar : MonoBehaviour { public GameObject crystalPrefab; public Material liveCrystal; public Material deadCrystal; public int lives; private int currentHealth; public int health { get{return currentHealth;} set { currentHealth = value; updateCrystals(); } } private List crystals = new List(); private void updateCrystals() { for(int i=0; i i) crystals[i].material = liveCrystal; else crystals[i].material = deadCrystal; } } void Start() { for(int i=0; i()); } health = lives; updateCrystals(); } // Update is called once per frame void Update() { } }