My script below is spawning to many gameobjects (fly)
What I want is to spawn one every2 seconds and from random places anywhere on screen
Im looking for a Script for Completley Random Spawning When I say random I mean locations it spawns from. ITS a 2D game
Not an array with set locations but I mean absolutely ANYWHERE on the screen all random ! I think it would include something like random x random y etc
Random meaning ANYWHERE ON THE SCREEN hopefully not using any list of arrays etc just simple script I can place on enemy’s and they can pop up anywhere on the screen every 2 seconds. I searched but since im new to scripting its hard to find and link one I tried for hours .watched so many tutorials but these need to be detail corrected and you have to know where to put the values I hope someone can help me and post or correct my script for me. Best karma to anyone who can get this to work for me
This is javascript
Please feel free to correct this script i have here and repost it
#pragma strict
var fly : GameObject;
var spawnValues : Vector2;
var flyCount : int;
var spawnWait : float;
var startWait : float;
var waveWait : float;
function Start () {
SpawnWaves ();
}
function SpawnWaves () {
yield WaitForSeconds (startWait);
while (true)
{
for ( var i : int= 0; i < flyCount; i++)
{
var spawnPosition : Vector2= new Vector2 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y);
var spawnRotation : Quaternion= Quaternion.identity;
Instantiate (fly, spawnPosition, spawnRotation);
yield WaitForSeconds (spawnWait);
}
yield WaitForSeconds (waveWait);
}
}