Spawning Multiple Enemies with a limit

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.

Your link doesn’t work.

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:

using UnityEngine;using System.Collections;using System.Collections.Generic; - Pastebin.com - 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. `

Please use code tags; the code above is impossible to read.

2 Likes

Edited and uploaded to the link. Sorry

Managed to find a good method :slight_smile: If anyone needs to know in the future let me know.