Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity Clones Delete other clones or set inactive something which is active Please Help

Discussion in 'Editor & General Support' started by MichaelDShark, Jan 24, 2016.

  1. MichaelDShark

    MichaelDShark

    Joined:
    Apr 11, 2015
    Posts:
    45
    Hello
    I have this really weird problem which I don't know how to fix

    Code:
    Code (CSharp):
    1. Spawn Enemies
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class SpawnEnemys : MonoBehaviour {
    6.  
    7.     public GameObject Enemy;
    8.     public GameObject rocketLauncher;
    9.     public int RocketCount;
    10.     public int EnemyCount;
    11.     public float spawnWait;
    12.     public float startWait;
    13.     public float waveWait;
    14.  
    15.     void Start()
    16.     {
    17.  
    18.         StartCoroutine (SpawnEnemy ());
    19.         StartCoroutine (SpawnRocket ());
    20.     }
    21.     IEnumerator SpawnEnemy()
    22.     {
    23.         yield return new WaitForSeconds (startWait);
    24.         while(true)
    25.         {
    26.             for (int i = 0; i < EnemyCount; i++)
    27.             {
    28.                 Vector2 spawnValues = new Vector2(Random.Range(-3.24F, 4.31F),5.92F);
    29.                 Instantiate (Enemy, spawnValues, transform.rotation);
    30.                 yield return new WaitForSeconds(startWait);
    31.             }
    32.             yield return new WaitForSeconds(waveWait);
    33.         }
    34.     }
    35.    
    36.     IEnumerator SpawnRocket()
    37.     {
    38.         yield return new WaitForSeconds (startWait);
    39.         while(true)
    40.         {
    41.             for (int i = 0; i < RocketCount; i++)
    42.             {
    43.  
    44.                 Vector2 spawnValues = new Vector2(Random.Range(-3.24F, 4.31F),5.92F);
    45.                 Instantiate (rocketLauncher, spawnValues, transform.rotation);
    46.                 yield return new WaitForSeconds(startWait);
    47.             }
    48.             yield return new WaitForSeconds(waveWait);
    49.         }
    50.     }
    51. }
    Need any more information just ask
    Thank you
    Michael
     
    Last edited: Jan 25, 2016
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    The video is private and is not viable to the public(may be nice to make it not listed only).
    Second please use the code tag to make your code more readable.
     
  3. MichaelDShark

    MichaelDShark

    Joined:
    Apr 11, 2015
    Posts:
    45
    Code tag ? Also can you view the video now?
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
  5. MichaelDShark

    MichaelDShark

    Joined:
    Apr 11, 2015
    Posts:
    45
  6. MichaelDShark

    MichaelDShark

    Joined:
    Apr 11, 2015
    Posts:
    45
  7. MichaelDShark

    MichaelDShark

    Joined:
    Apr 11, 2015
    Posts:
    45