Keeping with Lists

Benjamin Lihn
2 min readDec 24, 2020

I began the day intent on correcting yesterday’s code in which I had gotten my enemy waves working, but the spawn enemy script could only call one enemy type prefab.

I had inadvertently caused myself some confusion on the spawn manager script because I was hesitant to strip/rewrite large blocks of the existing code. Instead, I had commented out many of the working lines and replaced them with new variable names, methods, etc. In doing so, I had created quite a bit of a messy network of names, and this was preventing my script from working completely.

Today I was successful in correcting the spawn manager code so that the enemy waves could be filled with any assortment of the four enemy prefabs that I had created previously. I accomplished this by reviewing and correcting the structure and alignment of the variable types: game objects, transforms, the list being used to store the object array, and the object array itself.

In the script example above, I’m using “newEnemies.add(enemy)” to add the instantiated object to the list. The list is used to keep track of how many enemy objects are not null, meaning “still alive.” This functionality is controlling when the spawn waves are called.

keeping track of “alive” enemies

My goals for tomorrow are to create at least one of the new enemy behaviors. I also plan to properly edit the enemy sprites; to make organizing them easier, I had already adjusted their color in the sprite renderer in the Unity inspector. This works short term, but it’s also changing the color on the enemy explosion, which I do not like.

I’d like to take an extra moment this holiday season to again express my gratitude to Jonathan and the GameDevHQ team, as well as Pono Shim at ACI/OEDB for their meaningful contributions and commitment to me and the other interns of this program. Heartfelt thanks to all involved!

--

--

Benjamin Lihn

Coding my future as a software developer; // if (attitude > 0) {progress ++;}