Click to Play!

Tuesday, May 13, 2014

Getting The Decoy Spell To Work


     One of the more complex spells in the game is the Decoy spell. It summons a hologram-like turret that shoots spells in the direction it's facing. Getting this thing to work properly was a lot more challenging than tossing out a fireball.



     This was tricky because I needed to face it face the same direction as the player, shoot it's own projectile every second, vanish then reappear as the player walks through it, and anchor all it's sprites in a way that allows for the turret to be placed at the player's feet automatically.

     Getting most of this to work was pretty straightforward. Copy/Paste and edit the Blast and Cut scripts for the projectiles, use 2D Toolkit to anchor the Decoy sprites at the lower center, and have the turret match the player's direction when it's created. The big problem was getting projectiles to line up with whichever turret created it. Unity doesn't have any "Find Nearest Object" method that I know of and it would take longer than I'd like to make multiple turrets work.


     I had to make a sacrifice at this point. So henceforth, there can only be one active Decoy at a time. In the end, it'll likely balance better. You can't raise an army to help you in battle this way and makes it more strategic. You need to carefully plan where to place the turret. I can also lower the magic cost because of this weakness, allowing you to essentially move it around by planting a new one as you need it.


     Having just one at a time let's me play around with other things too. I can make it so that enemies and enemy projectiles go straight through it just like Clover does. I can have the Decoys exist on a timer like the Hex spell and disappear after 6 seconds or after shooting 10 blasts. What if I increase it's lifetime as the spell levels up? What if the rate of fire and number of shots both increase? I get to have fun playing with whichever feels better and run with it.

     At the end of all this, I'm getting that gut feeling that this is what's best for the game. I'm glad I've got all the spells running and I'm ready to add some polishing touches then throw in an enemy to fight.

No comments:

Post a Comment