Road to Game Dev: The Final Boss. (Part 5: Attack Patterns)

Rowan Mcmanus
3 min readOct 8, 2021

--

Things get a little insane…

With all of our foundations in place, it’s time to dive into the nitty-gritty of creating attack patterns. This part can get a bit tedious, as there’s simply a lot of different attacks to create and set parameters for, so I’ll only showcase a few key examples. The bulk of the challenge will be in making everything work smoothly and communicate; once that’s done, most of the attacks can be created with basic coroutines and timers.

Firing Projectiles

In order for all of our attack patterns to function, they need to be able to actually fire. Since the components are separate, we want the boss to handle the actual attack itself so it knows what each component is doing; However, we also want the turrets themselves to be firing the components. So, we need our functions to be as reusable as possible. We already know that functions can pass and return variables — now we’re going to use that to pass and return prefab projectiles.

Mega Laser Barrage

Continuous lasers pose a new challenge. We want to fire them as part of attack sequences, however, we also want to end them early if the phase changes. Likewise, we may want them to rotate with a turret, and end early if that turret is destroyed. This means we have to keep them as children of the turrets, and create subroutines to both control the timing and destroy them if the turret is destroyed. Even more difficult, I want to create a “Tracer” before firing the giant lasers that will warn the player of the incoming danger. For now, let’s tackle the first challenge: a simple laser barrage separate from the turrets.

Now, what happens if we want the turret itself to actually fire the laser? Attaching it to the projectile container will kill any positional or rotational data we need for it, so we need the turret itself to “watch” the laser and destroy it.

Additional Attack Patterns

From here on out, most attack patterns will follow the same basic framework; a switch statement for the phase which grabs the parameters, and then a set of coroutines that control the timing of the attack. We also want them to be reusable; as an example, here’s how I made a spiraling/wave laser attack:

This function is nearly completely reusable; all you need to do is store the parameters in an array, and then call the specific set of parameters you need. Nearly all of our functions will follow this same scheme. Many will also behave similarly; starting with a swivel to warn the player, then firing projectiles at specific angles and times. The next step in the process is the tedious bit of applying these methods to each different attack you need. Once that’s done and they have all been tested, then it’s time for the core of the boss: The master AI!

--

--