PlaneRun/Assets/Scripts/flareParticle.cs

42 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class flareParticle : MonoBehaviour
{
public AnimationCurve speedCurve;
public AnimationCurve heightCurve;
public float distance,speedModifier, heightModifier;
private float t_speed, t_height;
public float flareTime;
private float t_scale = 2f;
public bool taken;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
flareTime -= Time.deltaTime;
if( flareTime <= 0)
{
t_scale-=Time.deltaTime;
transform.localScale = new Vector3(t_scale, t_scale, t_scale);
if (t_scale <= 0)
Destroy(gameObject);
}
if (t_speed < 1f)
t_speed += speedModifier * Time.deltaTime;
if (t_height < 1f)
t_height += heightModifier * Time.deltaTime;
transform.localPosition = new Vector3(0, heightCurve.Evaluate(t_height), speedCurve.Evaluate(t_speed) * distance);
}
}