Early Owl — Week 21: Back with the Battle Mode ready!

EarlyOwl
4 min readJan 2, 2022

Hey Everyone! Welcome to the 21st week of my game development. It’s been about 9 weeks since I posted my last update. Things were not okay on the personal front. So I took a break in between for about a month. It’s been only 4 weeks since I resumed my work. And with the start of the new year, I decided to restart the logging part of the process as well…

I have been trying to get the gameplay combat-ready up to this point. I am 90% there. Things are working as intended, but I do not like what I ended up with. This is the part where I have to test, change, tweak and test again.

Here’s the TLDR of the progress I have made so far:

  1. Created 4 types of weapons and 2 types of enemies.
  2. Created a generic pooling script that is more straightforward and is better to pool all sorts of different objects
  3. Earlier, the enemy detection was random. Now it’s more predictable (I learned how to use Lists!)
  4. I created a wave manager to spawn enemies in various order and combinations.
  5. Did some code optimization. For example, I updated the weapon upgrade system to avoid too many dependencies on other scripts and gameobjects.
  6. Wrote scripts to handle different game states — player mode, camera, etc. But I think I’ll have to change how it is dealt with sometime later. (I think I need a state-manager)
  7. And loads of bug fixes.

So let’s begin

Created some more enemies and weapons

I modeled and implemented new weapons and enemies. It was fun to model them and add them to the game. But after playing with it, I encountered some issues. So they will have to be remodeled drastically, notably the weapons. I’ll return to this soon.

Generic Pooling Script

Pooling is an optimization one needs if you need to spawn many game objects that are short-lived like bullets, bombs, enemies, etc. That way, you can reuse items already in the memory instead of loading new game objects.

There are many tutorials on pooling game objects, and they are pretty sophisticated. But I found it difficult to follow and more complex than I needed to be. I wanted a more straightforward implementation for loading all sorts of items without doing many initial setups for each. So I wrote this simple script.

Then I added this script to the object handling the spawning of different items. The spawning script calls the object pooling script’s ‘CallObj’ function to spawn the item. The object pooling script decides whether to instantiate a new object into the scene or load what is already in the memory. I’ll probably explain the workflow further separately in the future.

Enemy detection — First in, First out

Earlier, I detected which enemy was entering the detection radius using ‘TriggerEnter’ and the weapons lock to it. But as soon as a new enemy entered the detection area, the weapon would change its target. This was not what I wanted.

So I started using ‘lists’ to record all the incoming enemies. Then I coded the weapons to target the first one in the list. And when an enemy leaves the detection radius or dies, it gets removed from the list, allowing the weapon to target the next target in line. This proved much better and predictable for the players.

Wave manager

I created a wave-manager script to precisely control enemies’ size, type, and frequency. It was a pretty complicated script to write. So I planned it on the FigJam board.

And I was pleasantly surprised when it worked the first time without any bugs!!!! In the inspector, it looks like this:

Optimization, some more coding, and lots of testing

Then I spent quite some time refactoring the code, changing the upgrade system, creating a new Save system in JSON format, a camera system to switch between different cameras during different game modes, and some more tweaks.

What’s next?

I had created a bunch of battle levels. I am not super happy with it, but now I can test and tweak it. That’s going to be my focus for the rest of the month.

In the next 2 sprints, I’ll add some visual effects, HUD UI, and sound effects for game-feedbacks. And hopefully, I’ll have figured out the fun part of the battle by then.

That’s it for this week… See you next time.

I wish you the very best.

Originally published at https://www.theearlyowl.com on January 2, 2022.

--

--

EarlyOwl

📱 App coder, 🎮 Game creator, 📖 Storyteller - Sharing all that I learn along the way! Sincere hobbyist | Forever a Work in Progress | Learning out Loud