Heroes_of_Hiis/Assets/Project Files/Scripts/JoonasP/ShieldController.cs

27 lines
568 B
C#

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<Renderer>().material.SetColor("_Color0", Color.Lerp(endColor, startColor, health / 5));
if (health <= 0) Destroy(gameObject);
}
}