void Update () {
if
(currentResolution != resolution || points ==
null
) {
CreatePoints();
}
FunctionDelegate f = functionDelegates[(int)
function
];
float t = Time.timeSinceLevelLoad;
for
(int i = 0; i < points.Length; i++) {
Vector3 p = points[i].position;
p.y = f(p, t);
points[i].position = p;
Color c = points[i].color;
c.g = p.y;
points[i].color = c;
}
particleSystem.SetParticles(points, points.Length);
}
private static float Linear (Vector3 p, float t) {
return
p.x;
}
private static float Exponential (Vector3 p, float t) {
return
p.x * p.x;
}
private static float Parabola (Vector3 p, float t){
p.x = 2f * p.x - 1f;
return
p.x * p.x;
}
private static float Sine (Vector3 p, float t){
return
0.5f + 0.5f * Mathf.Sin(2 * Mathf.PI * p.x + t);
}