Files
BoostBaller/Assets/Scripts/GoalLight.cs
2020-01-27 16:31:38 +01:00

47 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GoalLight : MonoBehaviour
{
public float lerpSpeed = 2.0f;
public float intensity;
private Light light;
private bool resetLight = true;
private float lerpT = 0;
// Start is called before the first frame update
void Start()
{
this.light = GetComponent<Light>();
}
// Update is called once per frame
void Update()
{
if (this.resetLight)
{
this.lerpT -= Time.deltaTime * lerpSpeed;
light.intensity = Mathf.Lerp(0.0f, this.intensity, this.lerpT);
} else
{
this.lerpT += Time.deltaTime * lerpSpeed * 2f;
light.intensity = Mathf.Lerp(0.0f, this.intensity, this.lerpT);
}
if (this.lerpT > 1)
{
this.resetLight = true;
}
}
public void LightUp()
{
this.lerpT = 0;
this.resetLight = false;
this.light.enabled = true;
}
}