From the early stages of the design of Carnivore Land, we were against the idea of having enemies spawn in fixed locations in the game. Having enemies in fixed locations would have killed any replay value because as soon as you learn the spawn locations and patterns, the enemy waves become super repetitive.
Instead, we created a randomized spawning system inspired from the spawning system of Left 4 Dead. We have created a central entity that handles all the enemy spawns and chooses where and how many enemies to spawn based on a set of predefined values and random attributes. Confused? Let me explain.
We have the player object. The player object is the center of the spawning system. All enemies are spawned around him. We also have a vector of where the player is looking and where he is moving towards. Let’s say that the spawn manager entity selects to spawn enemies to the back of the player movement vector and close enough to him so that they will attack from behind. Also, it selects that the spawned enemies of the wave will be very aggressive and will start chasing the player as soon as they are spawned. So it selects a random location to the back of the movement vector of the player and checks for validity. A spawn point is valid if it is on the level’s navigation mesh. If the point is not valid, it tests a new random location and retries, until it finds a valid point or a counter is reached where it retries at a randomized later time. If the spawn point is valid, it checks the spawn point of the next enemy for validity, etc.
The following picture depicts the valid spawn area for the enemies behind the player. The red area is invalid because it is inside the camera view, while the green area is valid because it is behind the player and outside of the camera view.
The following picture depicts the camera view for the aforementioned enemy spawn scenario.
The spawn manager entity controls the following features of the spawned enemies:
Movement state (chase the player, stand still or wander the level)
But how the spawn manager decides what and where to spawn? Weights and probabilities. All of the attributes that are controlled by the spawn manager are weighted randomized. When a wave is spawned, these weights are changed to reflect the probabilities of the attributes that the next waves will have.
Regarding the spawn location of the enemies, the spawn manager uses a similar weighted system to select in which direction from the player the enemies will be spawned. Also, there is a timer based weight on the look direction of the player. For example, if the player is still then, after a small interval, there is a greater probability for enemies to be spawned in the direction that the player is looking.
To sum up, the enemies are spawned by a central entity that monitors past spawned waves and player behaviour. The system uses a weighted randomized mechanism to choose the location, the numbers and the attributes of the spawned enemies.
Carnivore Land has been released on Itch.io as early access at: http://dwcrew.itch.io/carnivore-land
You can vote for Carnivore Land on Steam Greenlight if you like it: http://steamcommunity.com/sharedfiles/filedetails/?id=454770185
For more information please visit http://carnivoreland.com/