Search Unity

Spawning Multiple Enemies with a limit

Discussion in 'Scripting' started by CardDeath, Jan 26, 2015.

  1. CardDeath

    CardDeath

    Joined:
    Aug 1, 2013
    Posts:
    5
    Hey guys, rather than me posting the whole thing again I will post a link to my question over on Unity Answers:

    http://answers.unity3d.com/questions/886032/spawning-multiple-enemies-with-a-limit.html

    Basically I don't know how to write this code in a neat fashion so it's efficient, it's also broken at the moment as well and I can't see why.

    If anyone can see my other link and provide any advice that would be fantastic!

    Thank you so much.
     
  2. Sbizz

    Sbizz

    Joined:
    Oct 2, 2014
    Posts:
    250
    Your link doesn't work.
     
  3. CardDeath

    CardDeath

    Joined:
    Aug 1, 2013
    Posts:
    5
    I will post the question here:

    Hello there, I've looked around on Google and Unity Answers but nothing was quite right so I wanted to share my piece. Basically I'm making a sort of 3rd person space invaders game that's set in the past and I have different enemy types. Each enemy needs to be limited per level, this is how it looks for each individual level script for the enemy spawn:

    http://pastebin.com/Y42gUhuR - My apologies I don't know how to format the code on the website, it just placed it in a unreadable manner.
    As you can see there is a lot of repeating code with slight changes which isn't good practice and I wouldn't want my code this way. Also the spawning isn't working as some of the logic must be wrong at the moment. If anyone can help me out to write this in a more clear and concise way. I need to limit the number of enemies spawned on each level by checking if the maximum spawn limit is reached.

    Thank you for your time. `
     
    Last edited: Jan 27, 2015
  4. toreau

    toreau

    Joined:
    Feb 8, 2014
    Posts:
    204
    Please use code tags; the code above is impossible to read.
     
    ldb and Sbizz like this.
  5. CardDeath

    CardDeath

    Joined:
    Aug 1, 2013
    Posts:
    5
    Edited and uploaded to the link. Sorry
     
  6. CardDeath

    CardDeath

    Joined:
    Aug 1, 2013
    Posts:
    5
    Managed to find a good method :) If anyone needs to know in the future let me know.