float CustomRandomRange(float min, float max) { // Let's not get too crazy here, don't let them get away with negative-to-positive ranges min = Mathf.Abs(min); max = Mathf.Abs(max); // Sometimes coders make mistakes, let's just clean it up for them if (max < min) { float tmp = min; min = max; max = tmp; } // Sometimes coders are sneaky, we can't let the max = the min! if (max == min) { max += 5.0f; // because 5 is a good number } // There are lots of possibilities! We should create an array to store them all. float[] fRange = new float[(int)(max-min) * 200]; // Populate the array by incrementing through the ranges. for (float i = max*-1; i <= max; i += 0.01f) { if (i > (min*-1) && i < min) i = min; fRange[(int)(i < 0 ? (i + max) * 100 : (i * 100))] = i; } // Now that we've stored the results, let's select one at random!!! return fRange[Random.Range(0, (int)(max-min) * 200)]; }