1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-22 08:24:17 +00:00
gravity-fusion/Assets/Components/Disappear.cs

36 lines
658 B
C#
Raw Normal View History

2019-10-06 15:44:41 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Disappear : MonoBehaviour
{
public float timeLeft;
protected Particle particle;
public float FractionLeft {
get {
return timeLeft / particle.Duration;
}
}
protected void Awake() {
particle = GetComponent<Particle>();
}
private void Start() {
ResetTimer();
}
public void ResetTimer() {
timeLeft = particle.Duration;
}
private void Update() {
timeLeft -= Time.deltaTime;
if(timeLeft < 0) {
Destroy(this.gameObject);
}
}
}