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

@@ -55,7 +55,6 @@ public class ActionGestureInteraction : MonoBehaviour
Vector3 spawnPoint = transform.position + playerCamera.transform.forward;
spawnPoint = new Vector3(spawnPoint.x, spawnPoint.y + 1, spawnPoint.z);
GameObject shield = Instantiate(objects[1], spawnPoint, Quaternion.Euler(-90, playerCamera.transform.eulerAngles.y - 180, 180));
Destroy(shield, 5);
}
else
{

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);
}
}