Looping

Works very well thanks for the effort. The code at the start of the video is different than the one ended in the previous video - not a big deal easily fixed - but still all what I get is the first wave not the second one what did I miss ???!!!

It’s hard to tell what you missed if you just state your problem and ask what you missed. Things like screenshots and code you think might be the offender help a lot. Lot’s of folks willing to help here, but I don’t think any of us have a functioning crystal ball. Maybe Rob :wink:.

Thanks for your interest to help.

I missed to mention it was working perfectly till I put the last lecture modifications. New enemy (Enemy Blue is added with he same EnemyPathing script and added to wave 1 and 3 but on running the game as in screen shot (Running game) it was not initiated ?! thanks for help

Kamel Alkateb


Mailtrack

Sender notified by

                [Mailtrack](https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&)
                31/08/18, 10:26:41

a bit more digging if I change the starting wave number it runs that wave. I concluded that the for loop doesn’t add the increment and move to the next wave. The script compiled and the game was running but only the first wave ? All paths and enemies z axis are checked :wink:

thanks for help


Mailtrack

Sender notified by

                [Mailtrack](https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&)
                31/08/18, 11:23:08

Does it keep looping starting wave you set, or does it run your starting wave once and then stop?

EDIT: Looked at the changes for that lesson. Guessing you haven’t set “looping” to true in your enemy spawner object.

Stops after the first wave if the loop is not ticked and keep looping the first wave if it is ticked


Mailtrack

Sender notified by

                [Mailtrack](https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&)
                31/08/18, 18:02:20

You might paste your spawner code here and I’ll walk you through what’s happening.

Thanks a lot for your time and help. I pasted it below and attached it as word. doc file. I hope wouldn’t cause you loss of much time. I also included screenshots for the enemies and waves settings in the inspector.

Thanks again and God Bless you.

public class EnemySpawner : MonoBehaviour {

// Configuration Parameters

[SerializeField] List<WaveConfig> waveconfigurations;

[SerializeField] int startingWave = 0;

[SerializeField] bool looping = false;



//                   +++++++++++++++++++++++++++++++++++++++++

//_____________________________________________________________________________________________________

   // Use this for initialization

   IEnumerator Start () {

    do

    {

        yield return StartCoroutine(SpawnAllWaves());

    }

    while (looping);

    

   }

   private IEnumerator SpawnAllWaves()

{

    for (int waveIndex = startingWave; waveIndex< waveconfigurations.Count; waveIndex++)

    {

        var currentWave = waveconfigurations[startingWave];

        yield return StartCoroutine(SpawnAllEnemiesInWave(currentWave));



    }

  

}

   private IEnumerator

SpawnAllEnemiesInWave (WaveConfig waveconfigObject)

}

for ( int enemyCount=0; enemyCount<waveconfigObject.GetnumbeOfEnemies();enemyCount++)

    {

        var newEnemy = Instantiate(waveconfigObject.GetenemyPrefab(),

           waveconfigObject.GetWaypoint()[0].transform.position,

           Quaternion.identity);

        newEnemy.GetComponent<EnemyPathing>().SetWaveConfig(waveconfigObject);

        yield return new WaitForSeconds(waveconfigObject.GettimeBetweenSpawns());

    }

   

}

}


Mailtrack

Sender notified by

                [Mailtrack](https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality6&)
                01/09/18, 08:53:28

var currentWave = waveconfigurations[startingWave] is the problem line. When I get around a computer I’ll make a pass at helping you understand how better to read through your code when you’re looking for bugs. See if you can figure out what part of that line needs to change before then.

Wonderful it seems I messed the game yet again and have to rebuild it (version 5) so I would be grateful if you don’t tell me before 48 hours. It is so exciting. I reached the scrolling background and now I have to start again from scratch nearly. Thanks a lot


Mailtrack

Sender notified by

                [Mailtrack](https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&)
                01/09/18, 16:09:41

Ouch. I can put off running through it. Not sure if Rick plans on covering version control at some point in this course, but it’s something you might think about figuring out if you find yourself frequently restarting your projects for mess-ups.

I found the for loop in SpawnAllWaves yield return parameter was currentWave instead of waveIndex. That corrected it and I am back on track. Thanks for not rushing with the answer :smile:


Mailtrack

Sender notified by

                [Mailtrack](https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&)
                02/09/18, 16:15:39

Privacy & Terms