Answers for "Create an array that chooses between four random numbers (C#)"
http://answers.unity.com/questions/1174734/make-an-array-that-chooses-between-four-random-num.html
The latest answers for the question "Create an array that chooses between four random numbers (C#)"Answer by Waka-Takaki
http://answers.unity.com/answers/1174742/view.html
You need to perform Random.range with an int, not a float.
int selection = Random.Range(0, angleArray.Length - 1);
int angle = angleArray[selection];
Then apply your angle to the velocity using callen's method belowThu, 21 Apr 2016 15:58:29 GMTWaka-TakakiAnswer by callen
http://answers.unity.com/answers/1174740/view.html
This should fix it:
velocity = new Vector2 (Mathf.Cos (angle*Mathf.Deg2Rad), Mathf.Sin(angle*Mathf.Deg2Rad));
Cos and Sin use radians, but youre giving it degrees. The built-in consts Deg2Rad and Rad2Deg are there for this reason.Thu, 21 Apr 2016 15:16:36 GMTcallenAnswer by Dave-Carlile
http://answers.unity.com/answers/1174739/view.html
Cos and Sin expect an angle in radians but you're passing in degrees. You can convert from degrees to radians by multiplying degrees by [Mathf.Deg2Rad][1].
Another option would be to just store the vector in your array directly so you don't need to do the trig.
[1]: http://docs.unity3d.com/ScriptReference/Mathf.Deg2Rad.htmlThu, 21 Apr 2016 15:16:03 GMTDave-Carlile