Random.InsideUnitSphere generate on outline

Hello,

I need to get a few objects to spawn at a location away from the player at a distance of 250 and on a sphere.
Using Random.InsideUnitSphere takes care of the location. But the problem is I cant think of an efficient way to limit the position of my object to the outline of the sphere.

I am working on VR for Cardboard so performance is a must, the only thing I can think of is generating a position and checking if that one is on the outer layout, if not generate again (using a while loop to check the values…, but this has proven to be very inefficient)

    void Update ()
    {
        playerPosition = GameObject.Find("Head").transform.position;
        if (amountOfObjectCreated < amountOfObjectsToCreate)
        {
            InstantiateRandom();
        }
    }
    void InstantiateRandom()
    {
        Vector3 sphericalPosition = Random.insideUnitSphere * 250;
      
        //Constrain position
        sphericalPosition.y = Mathf.Abs(sphericalPosition.y);
        Vector3 objectPos = sphericalPosition + playerPosition;

        GameObject temp = Instantiate(objectToCreate, objectPos, Quaternion.identity) as GameObject;
        temp.AddComponent<GazeImproved>();
        amountOfObjectCreated++;
    }

Here’s my function for ‘OnUnitSphere’:

public static UnityEngine.Vector3 OnUnitSphere(this IRandom rng)
{
    //uniform, using angles
    var a = rng.Next() * MathUtil.TWO_PI;
    var b = rng.Next() * MathUtil.TWO_PI;
    var sa = Mathf.Sin(a);
    return new Vector3(sa * Mathf.Cos(b), sa * Mathf.Sin(b), Mathf.Cos(a));
}

from:

Of course, it’s designed to use my object IRandom interface because I gave object identity to unity’s Random class.

Rewritten for Unity Random without the object model:

public static UnityEngine.Vector3 OnUnitSphere()
{
    //uniform, using angles
    var a = Random.value * Mathf.PI * 2f;
    var b = Random.value * Mathf.PI * 2f;
    var sa = Mathf.Sin(a);
    return new Vector3(sa * Mathf.Cos(b), sa * Mathf.Sin(b), Mathf.Cos(a));
}

So you would say:

var v = OnUnitSphere() * 250f;

Oh well ok, thx for that. Uing that gave me the effect that I wanted to achieve tyvm ^^