Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float x = 0;
- float posX = 0;
- const float MAXINTERVAL = 5;
- while (x < 1)
- {
- // 1 / amount of objects on spline
- var temp = Instantiate(inst);
- temp.transform.position = new Vector3(posX, 0, 0);
- x += 1f / 11f;
- posX += MAXINTERVAL - Gaussian(3f, 0.5f, 0.25f, x);
- Debug.Log(Gaussian(28f, 0.5f, 2, x));
- }
- private float Gaussian(float a, float b, float c, float x)
- {
- //'a' is the height of the curve
- //'b' is the center of the curve (i.e. the highest point, if 'b' = 2, the result will be 'a' if 'x' = 2)
- //'c' is the width of the curve
- //
- // .-.
- // / \
- // / \
- // ___,,..-' '-..,,___
- //
- return a * Mathf.Exp(-((Mathf.Pow((x - b), 2)) / (2 * Mathf.Pow(c, 2))));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement