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() { GetComponent().Play("Shield_init_anim"); } // Update is called once per frame void Update() { health -= Time.deltaTime; GetComponent().material.SetColor("_Color0", Color.Lerp(endColor, startColor, health / 5)); if (health <= 0) { GetComponent().Play("Shield_exit_anim"); Destroy(gameObject, 0.25f); } } }