Advertisement
Guest User

Spawn_Bee

a guest
Oct 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Spawnabelha : MonoBehaviour {
  6.    
  7.         public GameObject abelha;
  8.         public Vector3 spawnValues;
  9.         public int abelhaCount;
  10.         public float spawnWait;
  11.         public float startWait;
  12.         public float WaveWait;
  13.  
  14.  
  15.         void Start()
  16.         {
  17.             StartCoroutine (SpawnWaves());
  18.         }
  19.  
  20.         IEnumerator SpawnWaves ()
  21.         {
  22.             yield return new WaitForSeconds (startWait);
  23.             while (true)
  24.             {
  25.                 for(int i=0; i<abelhaCount; i++)
  26.                 {
  27.                     Vector3 spawnPosition = new Vector3 (spawnValues.x, Random.Range  (-spawnValues.y, spawnValues.y), spawnValues.z);
  28.                     Quaternion spawnRotation = Quaternion.identity;
  29.                     Instantiate(abelha, spawnPosition,spawnRotation);
  30.                     yield return new WaitForSeconds (spawnWait);
  31.  
  32.                 }
  33.             yield return new WaitForSeconds(WaveWait);
  34.             }
  35.         }
  36.        
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement