shield color change on lifetime
This commit is contained in:
@@ -12,6 +12,7 @@ GameObject:
|
||||
- component: {fileID: 772404450966566002}
|
||||
- component: {fileID: 3268723311598239928}
|
||||
- component: {fileID: 7564575873016353892}
|
||||
- component: {fileID: 3597675138378626114}
|
||||
m_Layer: 0
|
||||
m_Name: shield_spell
|
||||
m_TagString: Untagged
|
||||
@@ -97,3 +98,18 @@ BoxCollider:
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 3.8, y: 0.3, z: 2.0000007}
|
||||
m_Center: {x: 0, y: -0.0046907673, z: 0.000000001118366}
|
||||
--- !u!114 &3597675138378626114
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3917053023338471789}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: add865683e185ac43b2093091d499b6a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
health: 5
|
||||
startColor: {r: 0.019607844, g: 0.77254903, b: 0.77254903, a: 0}
|
||||
endColor: {r: 0.8666667, g: 0.43137255, b: 0.13333334, a: 0}
|
||||
|
||||
@@ -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