# Smooth random number C#.

I’m making game and I need smoother random generation because after some time I can see bad things in my games like very different numbers.
Ok so for test I wrote this script:

``````for (int i = 0; i < 1000; i++)
Debug.Log (Random.Range(-9, 9));
``````

In unity editor in console selected tab Collapse. Result:

``````-9  -   61
-8  -   51
-7  -   45
-6  -   66
-5  -   64
-4  -   59
-3  -   53
-2  -   63
-1  -   44    44
0  -   48
1  -   45                           23! It's so big difference between number.
2  -   53          67 - 44 = 23     I need that this difference will be less than 5
3  -   59                           And it will be great if it will be
4  -   63                           less than variable.
5  -   67    67
6  -   55
7  -   46  46
8  -   58  58   58 - 46 = 12        And between numbers gap is too big.
``````

Can anyone help how to make smooth random generation with very little noise(gap of 3 etc.)?

int r = Random.Range(0, 100); // start somewhere between zero and 99

``````for (i = 0; i < 1000; i++){
r += Random.Range(-3, 4);  // add somewhere between +/- 3
Debug.Log(i + " : " + r);
}
``````