SHMUP 2.1?

So it's week three and with everything we've added to the SHMUP plus small edits here and there for quality of life reasons, we add one last "feature"?

Area of Effect Damage. Like you know, those spells in World of Warcraft that have a large circle on the ground where you can probably fit 30 or so characters if the game had collisions, or as many as you want until your client/PC couldn't handle it anymore and crashes. This thing...

Image from the League of Legends wiki about Spell Indicators



There's a twist on this AOE implementation for the SHMUP though. Instead of dealing a fixed amount of damage to anybody who was in the area, the damage was based on the target/enemies location within the area (The area was a sphere, so the y-axis was used).

Challenge numero uno (I think that's how you spell it):
How do we go about dealing damage to any enemy within the area?

It was actually quite easy to solve that, <base_damage> * (1 - <distance_to_enemy> / <radius>). Take into account the distance of the enemy (from the centre of the area) and divide that by the radius of the area.
And getting all the enemies to take damage in the first place is by having the area as a trigger and an OnTriggerEnter function with a script attached to the prefab.

Whenever OnTriggerEnter is called, simply check the tag, if it's an enemy, add them to a list. Done and done. Now we have a giant list full of enemies that we just need to loop over and calculate the amount of damage to deal to each one. Something that seems complicated in theory but quite simple once you see a working example of it and there's room to add a personal touch to these types of things.

For this version of our SHMUP, once all the enemies die from our nuke. There's most likely missiles still moving about actively searching for a new target, so we can clean them up if any missiles end up in the nuke area.

I've personally never used or really seen a nuking effect quite like what we made this week, instantiating a empty GameObject that when spawned, increases it's radius on the SphereCollider for a lifetime of 0.2 seconds and then dealing damage to everything within the area. Hopefully I'll be creating an AOE system in later games as they really can be a nice quirky gameplay mechanic.

Our nukes will block out the Sun!

Tom Lynn

Read more posts by this author.

Australia http://rubbix.net