shield color change on lifetime

This commit is contained in:
joonasp
2022-04-18 14:14:48 +03:00
parent b3c991bd09
commit 4922174840
12 changed files with 845 additions and 822 deletions

View File

@@ -4,6 +4,12 @@ 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()
{
@@ -13,6 +19,8 @@ public class ShieldController : MonoBehaviour
// 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);
}
}