38 lines
983 B
C#
38 lines
983 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[ExecuteAlways]
|
|
public class Flame : MonoBehaviour {
|
|
|
|
[Range(0, 1)]
|
|
public float Aliveness = 1;
|
|
public ParticleSystem System;
|
|
public float AddFuelEffect;
|
|
|
|
private float SecretBoost = 0f;
|
|
|
|
// Start is called before the first frame update
|
|
void Start() {
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update() {
|
|
if (AddFuelEffect > 0f) {
|
|
SecretBoost += 0.2f / (SecretBoost + 0.2f) * 2f * AddFuelEffect;
|
|
AddFuelEffect = 0f;
|
|
}
|
|
if (SecretBoost > 0) {
|
|
SecretBoost -= Time.deltaTime * 3;
|
|
}
|
|
float TotalAliveness = Aliveness + Mathf.Max(SecretBoost, 0);
|
|
|
|
System.startLifetime = 1.2f + 1.8f * Aliveness;
|
|
var em = System.emission;
|
|
em.rateOverTime = 20 + 80 * TotalAliveness;
|
|
var vol = System.velocityOverLifetime;
|
|
vol.radial = 0.7f * TotalAliveness;
|
|
}
|
|
}
|