Excuse my noobness, as I’m very new to coding. I’m trying to create an array with 10 cells, each filled with a random number between -5 and 5 (z value). I’ve written a few different codes but always run into the error that System.Random cannot be converted to a float value. Is there a better way to do this?
You need to explicitly make the 5 or -5 a float by adding an f or the Random.Range function will return an int (Unity - Scripting API: Random.Range)
float[] floatsArray = new float[10];
for (int i = 0; i < floatsArray.Length; ++i)
{
floatsArray *= Random.Range(-5, 5f);*
}