Instantiate gameobject in random point around a sphere

i want help to create a script that instantiates gameobjects around a sphere!!
please help and give me advices

I faced a similar problem when baking lighting with a large number of lights, and the result was unpredictable. When the light was baked again, different light sources were turned off. Perhaps increasing the maximum number of light sources on the scene will help: [Edit] > [Project Settings] > [Quality] > (Choose Active Quality Level) > [Pixel Light Count]

1 Answer

1

Try declaring three empty float variables, (each for x, y, and z) randomize each of them, and ram them all into the Instantiate method.

    public float ranX;
	public float ranY;
	public float ranZ;

	public float sqrRadius;

	public GameObject objectToInstantiate;

And now the Randomization plus the Instantiation.

        ranX = Random.Range (-sqrRadius, sqrRadius);
		ranY = Random.Range (-sqrRadius, sqrRadius);
		ranZ = Random.Range (-sqrRadius, sqrRadius);

		Instantiate (objectToInstantiate, new Vector3 (ranX, ranY, ranZ), Quaternion.identity);

i know that and i already have this script but i want to that be spawned in touch with the sphere . thanks for help anyway