Enemy development


Enemy development 

Hi! I’ve been busy developing the ‘enemy part’ of the game. However, I managed to make a huge progress in this part. I’m also including some problems that I had during the development of this part. Maybe it would be helpful for you..

Enemy variants and movement

As I posted before, there are three types of enemies: following a pattern, trying to chase the player and minibosses. I started to think in a way to increase the difficulty of these enemies once the player reaches new levels.

So the first thing that I did was to develop a way to modify the enemies’s stats based on levels. I created a scriptable object that manages all this information. This allows me to fine tune the parameters in an easy way.


Also, I make some variants of the assets in order to make the game more colorful. Since the stats of the enemies are stored in the scriptable object. I managed to separate the stats and the look of the airplane (prefab asset). 


This separation is important for me, because I can manage to instantiate any airplane based on its “type/stats” and later manage to associate the asset. In order to do that, I created two main objects: enemy spawner and object pooler.

The object pooler is responsible for instantiating a pool of airplanes and storing them in categories piles. Later on, the enemy spawner can take some of these instantiated assets and merge them with the corresponding stat info. Once the airplane asset is not needed, the object pooler will deactivate it and store its reference on the pool. (I implemented a Queue stack for that)


Every time that the enemy spawner calls a new enemy asset from the object pooler, it will give to the enemy asset the information about movement, stats and other data; based on information about the wave. This is also a scriptable object that has the information about the enemy’s stat, enemy movement, and other data. 

Enemy Spawner  ←—----> Object Pooler

(wave config)                (level information)

The following images show the waypoint pattern and chase pattern. Minibosses are a variant of the waypoint variant.



Problems found

These 3 problems where the most time consuming issues that I faced in this stage: 

1.- Race condition with the object pooler: The object pooler instantiates the enemies based on the quantity and type of the airplanes:  

 

Then, it creates a table (dictionary) where it stores the references of each of these elements. This is done to later, be able to manage the deactivation and activation of the objects in the pool. However, I put the method to create this table on ‘Start’. And I was getting a null reference, since the spawner was trying to get the info from this table, but it was not already finished yet. So I moved the method to ‘Awake’ instead.

2.- Prefab and  camera orientation: because I’m still implementing these systems in a ‘testing scene’ I didn’t notice that the camera was orientated in a way where the x and z axis were reversed. Also, the airplanes' prefabs have different orientations. When I started to apply some rotation to the enemies, I got strange results. Later on I noticed these problems.

3.- Reset conditions on the airplanes: I forgot to reset some internal conditions when I put the enemies back into the object pool. Because of that omission, on the second call of these elements, there were strange behaviours once they would be called later. I implemented a ‘reset’ method to fix this issue.

Next steps:

  • Player’s stats, health and perks/buffs 
  • Improve player’s movement

Leave a comment

Log in with itch.io to leave a comment.