Making enemy spawners function correctly -- Owen Meyers

     In order to properly give the player a new challenge throughout the different levels of the game, as well as giving the sense of a "reshuffled simulation," it is very important to have random enemy spawners throughout the levels. A simple object in the level that has a position and rotation, as well as spawn chances is all that is needed. The solution is simple, and I will outline how the system functions here.

    The first thing needed is a spawn position and rotation. This is easily done in blender through an object called "Spawner." Note that this is actually just a cube that is only visible in blender. Its matrix is output from the map by a blender script, along with its name. Included in the name is an alphanumeric sequence corresponding to a spawn chance for a specific enemy. When the level begins, every spawner that could be generated is iterated through. A number is rolled, and an enemy is spawned according to its spawn chances, which could include nothing.

    The next thing needed is balance. It wouldn't be fair to have a room with 5 spawners spawn 5 enemies when the player has no ammo and no upgrades. Thus, the max number of enemies spawned in any given room is capped at the floor number. This way, only 1 enemy can spawn per room in floor 1, while on the final floor, a max of 5 enemies can spawn in to swarm the player. This helps to give a constant escalation, as more and more enemies must be juggled the closer the player gets to the final part of the game.


An example of a spawner in a level file. The code denotes that this spawner has a 30% of spawning a pistol enemy, a 50% chance of spawning a shotgunner enemy, and a 20% of spawning nothing.


Comments

Popular posts from this blog

Adding assets to every enemy -- Owen Meyers

Sphere to AABB collision