Answers for "The algorithm of curve in Shuriken Particle System"
http://answers.unity.com/questions/438407/the-algorithm-of-curve-in-shuriken-particle-system.html
The latest answers for the question "The algorithm of curve in Shuriken Particle System"Answer by Varaughe
http://answers.unity.com/answers/1754901/view.html
If you want to know what is the exact equation behind an AnimationCurve,
you should check [Runtime Curve Editor][1] (from Unity Asset Store).
The package replicates 100% the equation by which the Animation Curve built-in editor plots the curve.
Also the package supports visually editing of pairs of curves, which is used in the particle editor.
[1]: https://assetstore.unity.com/packages/tools/gui/runtime-curve-editor-11835Sat, 25 Jul 2020 17:09:25 GMTVaraugheAnswer by Bunny83
http://answers.unity.com/answers/438613/view.html
The Shuriken Particle System just uses Unity's AnimationCurve class and the built-in editor. Yes they are bezier curves, but the control points are calculated by the "tangent angle".
***edit***
Finally had some time and i quickly created an editor window with a CurveField. This is the result:
![Curve][1]
Here's the most important part of my sample code:
float w = R.width;
float h = R.height;
var keys = curve.keys;
for(int i = 0; i < keys.Length-1;i++)
{
Keyframe K1 = keys[i];
Keyframe K2 = keys[i+1];
Vector2 start = new Vector2(K1.time*w,K1.value*h);
Vector2 end = new Vector2(K2.time*w,K2.value*h);
float d = (end.x-start.x) / 3.0f;
float a = h / w;
Vector2 st = start + new Vector2(d,d*a*K1.outTangent);
Vector2 et = end + new Vector2(-d,-d*a*K2.inTangent);
Drawing.BezierLineGL(start,st,end, et,Color.red,20);
}
So basically you just take 1/3 of the distance between two points on the x-axis as the x position of the control point. When your viewing area's aspect ratio differs from 1.0 you have to correct the y value accordingly (like i did).
So at the end you have a start point (start) two control points (st, et) and the end point (end) for each segment to draw a cubic bezier between two KeyFrames.
ps: R is a Rect which represents the drawing area's size.
[1]: /storage/temp/185268-curvesample.pngMon, 15 Apr 2013 14:14:11 GMTBunny83