shield color change on lifetime
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user