Road to Game Dev: The Final Boss. (Part 2: Building the Boss)
With our core idea in mind, it’s time to actually build the boss out. This can be a bit of a tedious process, so I won’t cover it in detail, but you can see a scaled-down version of the end result above!
Preparing the Components
First thing’s first; we already know that every single turret will be destructible, able to aim separately, fire independently, and more. This means they have to be treated as their own objects. To support this, we need to make prefabs for each of the turret types.
The basic components we know we’ll need are: The turret itself, a collider for the hitbox, a spawn location for projectiles, a controller script (which we’ll handle later), and some extra vfx for when it’s destroyed. Go ahead and create a parent which will hold the script, sprite, and hitbox, and then add the damage fx and an empty game object as our projectile spawner. A few components will actually need multiple spawn locations, but that’s simply a matter of adding more objects and lining them up where you want them to be!
Piecing Together the Boss
While this isn’t something new, the process can be a bit overwhelming just due to the sheer number of components involved. Here’s a peek at what the hierarchy looks like for my final result:
I decided that the boss would be fought in 3 stages, with each stage progressing once enough of the sub-components were destroyed. In order to organize this properly, I categorized each component into their respective phases, which will later also allow me to easily detect when a phase is completed. Each of these components also has to be located properly; this process requires a bit of creativity, but there’s also plenty of spots on the boss’s model that have plenty of space to place a turret.
Once you’ve located and placed each turret down, the boss needs a couple more things. I added in its own projectile container so that it could destroy any projectiles remaining on-screen when a phase is completed, as well as a container for “Transitions” and an AI Controller. While I could have done both of these on the “master” script for the boss, that script is going to end up being gigantic as it is, so splitting these pieces out a bit helps with organization and makes it a bit easier to modify smaller components down the line. The transitions container simply stores prefabs containing information about how the boss will move, while the AI Controller is the “brain” that will handle all of the actual attack patterns. Next time, we’re going to return to the realm of code and start tackling the master scripts.