using System.Collections; using System.Collections.Generic; using UnityEngine; public class ShieldController : MonoBehaviour { public float health = 5; public Color startColor; public Color endColor; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { health -= Time.deltaTime; GetComponent().material.SetColor("_Color0", Color.Lerp(endColor, startColor, health / 5)); if (health <= 0) Destroy(gameObject); } }