Random Spawning Help

Ok so I've tried randomly spawning enemies two different ways and need a little help. The first way is

    var teleporter= gameObject;
var range= 10;

var waittime= 10;

var spawndistancemin= 10;

var spawndistancemax= 20;

var player= transform;

function Start() {


function PlayerCheck() {

if( Vector3.Distance(player.position, transform.position) > spawndistancemin);
if (Vector3.Distance(player.position, transform.position) < spawndistancemax);
go.transform.position = new Vector3 (Random.value * range, Random.value *range, Random.value *range);
yield new WaitForSeconds(waittime);

when I do it like that I get one randomly spawning object that spawns in a random position within proper ranges from the origin. The second way is

var allClear = true;
var teleporter= gameObject;
var range= 10;
function Update() {
var i= Random.value* range;
var j= Random.value* range;
var k=Random.value* range;
var pos=Vector3(i,j,k);

Instantiate (teleporter, pos, Quaternion.identity); 


function OnCollisionEnter() {
    allClear = false;

this give me constantly spawning objects within the appropriate ranges from the origin.

The main problem I have is that I want them to spawn within a certain range of the player not the origin. Also I dont want constatly spawning I want a certain amount to spawn then some time to pass and then more spawn. Any ideas?

Random has some useful class variables like `insideUnitSphere` which can help simplify the randomization.

If you have a point `Vector3(1,2,3)` that is relative to the world origin and you want it to be relative to a specific `Transform` you can just add the `Transform`'s position to the point. This moves the point to be just as far away from the `Transform` as it was from the origin in the same direction.

You can use WaitForSeconds.WaitForSeconds to pause between spawning groups of enemies.