Answers for "Random.Range Vector3"
http://answers.unity.com/questions/694692/randomrange-vector3.html
The latest answers for the question "Random.Range Vector3"Answer by rhodnius
http://answers.unity.com/answers/1650136/view.html
Here is the code if someone is needing it:
using UnityEngine;
public static class MathUtilities
{
public static void Random(this ref Vector3 myVector, Vector3 min, Vector3 max)
{
myVector = new Vector3(UnityEngine.Random.Range(min.x, max.x), UnityEngine.Random.Range(min.y, max.y), UnityEngine.Random.Range(min.z, max.z));
}
}
You can use it just by having any vector field and calling from it Random(minVector, maxVector)Fri, 19 Jul 2019 21:12:58 GMTrhodniusAnswer by wibble82
http://answers.unity.com/answers/694715/view.html
Your code effectively gives you a random position within a 'box', who's "min" corner is at minPosition and "max" corner is at maxPosition. There's no handy unity function to return you a random vector within a box unfortunately, however you could of course write your own little utility function to do it. Maybe create a class somewhere called 'RandomUtils', with a static function in called 'RandomVectorInBox'.
The Random.onUnitSphere, or Random.insideUnitSphere functions give you a random vector either on the surface of, or inside, a sphere of radius 1. Even if you then multiple the result by a random number you won't end up with an even spread and they wouldn't match the bounds of your box either. Hence I wouldn't recommend doing something with them.
So the simple answer is no - there isn't a nicer way of doing it! But you could write your own little utility function to do it to make your code a little cleaner.Fri, 25 Apr 2014 17:18:24 GMTwibble82