Spawning Logic - Antonio Roldan




This week I drafted and implemented logic for how I want our enemies to be spawned in our game. To start with I knew that I would need an empty game object that would act as our "spawn manager". There were three major considerations I wanted our manager to take into account when choosing where and what to spawn. I wanted there to be hordes of enemies but I wanted it to feel random in terms of how many and what types of enemies were spawning. I also wanted to be able to control the locations of the spawns and so to implement all of these requirements I started by creating another empty game object which will act as our spawn points.

On begin play I made our spawn manager add all of the spawn points to an array and at a set time interval we would choose a random spawn point. We would then choose a random number in a range, which for now I have set between 7 and 13 because that felt good, and we would spawn that many enemies in a random set radius with a random rotation around the spawn point. We also gave a probability to the two enemy types which I currently have set as 90% for the crawler and 10% for the spewer. The way I did this was to choose a random float between zero and one and if it was equal or below 0.1 it will spawn a spewer and otherwise it will spawn a crawler.

Lastly I wanted the time between spawns to gradually ramp up as the player progressed in the objective so to accomplish this we keep track of how many enemies have been killed in our game state. If the number of enemies reaches certain thresholds, which currently are at a quarter, half, three-quarters, and objective complete, the spawn rate will increase by a certain factor. I have it ramping up to up to double the spawn rate which means when we are waiting for extraction there will be new hordes spawning in random locations every ten seconds. Every single one of these variable values for the randomness and frequency of hordes will need to be tested and adjusted as we balance the game. 



Once I completed this I went into our stand-in defense level and placed spawn points all around the map as shown in the screenshot above.  After testing it out everything looked how I wanted but this made me realize a few issues that I am going to be facing in the future. For one I need to start thing about crowding behaviors of my AI as even though they do appropriately spread around the player when attacking, they seem to synchronize their movements which looks unnatural. They also seem to jitter a bit when they get too crowded which I need to find out why and how to fix it. For now however the functionality I was hoping for seems to be in place and is nice and parameterized so we can easily change aspects of this behavior. Below I made a short video of me showing this in action. I got rid of all spawn points and then placed three in a corner area inside of a wall to show the hordes spawning. 

Leave a comment

Log in with itch.io to leave a comment.