// Update is called once per frame void Update() { camLeft = Camera.main.ScreenToWorldPoint(new Vector3(0.0f, 0.0f, 100.0f)); camTop = Camera.main.ScreenToWorldPoint(new Vector3(0.0f, Screen.height, 100.0f)); camRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0.0f, 100.0f)); camBottom = Camera.main.ScreenToWorldPoint(new Vector3(0.0f, 0.0f, 100.0f)); if (camTop.z + 2.0f >= transform.position.z) { isSpawning = true; } if (isSpawning) { transform.Translate(new Vector3(0.0f, 0.0f, 10.0f * Time.deltaTime)); spawnTimer += Time.deltaTime; if (spawnTimer >= spawnOffset && spawnNumber > 0) { Vector3 spawnPoint = new Vector3(0.0f, 0.0f, 0.0f); spawnTimer = 0.0f; Transform t = Instantiate(obj, transform.position, transform.rotation) as Transform; GameObject enemy = GameGod.GetLibraryScript(names, t); spawnNumber -= 1; } else if (spawnNumber <= 0) { Destroy(this.gameObject); } } }
void SpawnUnit(Vector3 pos) { Transform t = Instantiate(obj, pos, transform.rotation) as Transform; GameObject enemy = GameGod.GetLibraryScript(names, t); }