An example of my code, lets say I have a solar system, center being the sun, this code will spawn all the planets around it randomly with a set radius for each planet, in the Vector3 I change and randomize the X and Z, leaving Y at 0.
This is the code, planetInt
is the number of planet in the for loop
, 0 being first planet up to the 8 planet.
private float orbitRadius = 3150f;
// Get Radius
float newOrbitRadius = orbitRadius * (planetInt + 1);
// Get Random Positon (here)
Vector3 randomPlanetPosition = new Vector3(Random.insideUnitSphere.x * newOrbitRadius, 0, Random.insideUnitSphere.z * newOrbitRadius);
How would I change the Vector3( X and Z)
to be in a specific zone, for example I want all the positions to be in the same area like this picture.
How do specify a specific angle like the multiple ones in this image, with Y being 0.