22 lines
814 B
C#
22 lines
814 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class Torch : MonoBehaviour {
|
|||
|
public Light Light;
|
|||
|
public Color NormalColor;
|
|||
|
public Color PanicColor;
|
|||
|
public float Lifetime = 3f;
|
|||
|
public float PanicLifetimeThreshold;
|
|||
|
|
|||
|
private void Update() {
|
|||
|
Lifetime -= Time.deltaTime;
|
|||
|
Light.color = Color.Lerp(Light.color, Lifetime <= PanicLifetimeThreshold ? PanicColor : NormalColor, 4f * Time.deltaTime);
|
|||
|
transform.localPosition = Vector3.Lerp(transform.localPosition, Vector3.zero, 12f * Time.deltaTime);
|
|||
|
transform.localRotation = Quaternion.Slerp(transform.localRotation, Quaternion.LookRotation(Vector3.forward, Vector3.up), 12f * Time.deltaTime);
|
|||
|
if (Lifetime <= 0) {
|
|||
|
Destroy(gameObject);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|