Just sweeping through here
TL;DR: Freakin Lazerâ„¢ now kills enemy pews, video below.
Next to adding some more settings to the options menu (FPS, VSync, primary fire mode) over the last two days, I also just added the possibility for projectiles to do sort of an area damage effect while flying around.
And what I am using that for is to make the Freakin Lazor deal damage to projectiles which essentially sweeps them up. Just like a broom.
At a first glance this may seem simple, but I ran into a number of special cases I had to deal with.
I had to make sure the projectiles are actually only being dealt damage along the beam and not in front or behind it, nor on either side, which was fairly simple once I fixed the math (two simple projections, nothing too amazing). But then it turned out that since the laser beam is made from multiple beams so that it can split up nicely, these beams started damaging and deleting each other, due to a bug in the beam-damage code (beams right now should not take damage).
Further, the beam was deleting the player's projectiles, so I had to make sure that those were filtered. Luckily each projectile know what it can it, so it is easy to identify 'enemy projectiles'.
While I was at it I made the system be more flexible than described here, so it can optionally also do damage to enemies, or even players, has the choice of doing damage over time, or instantly, and even ignoring friendly fire is actually a toggle.
With that in place it is now super simple to actually add the effect to a projectile, by just adding a tiny bit of code to the appropriate script file:
- Code: Select all
{ "pathDamage" : {
"width" : 0.4, // width of the area around the projectiles 'flight path'
// that receives damage
"damage" : 50, // the amount of damage, either per second or instantly
"singleHit" : false, // whether the damage is instant (true) or over time (false)
"hitProjectiles" : true // dealing damage to projectiles? check.
// more settings here if needed
} },
And the result looks like this: