Day 14- 11/10/20

Dylan Murayama
3 min readNov 11, 2020

Coming to an end! My Space Shooter Program is finally nearing the end. I am on the final steps before I go through and polish everything up a bit more. I am working through my Boss enemy and then have to implement the wave manager and then off to the final polishing I go. As for the polishing, there is a decent amount of animating I need to do. Mostly to my new enemies and re-adding the player death animation. And from constant running, there is one instance that crashes my game, but I need to do more testing to fully figure out the cause of this. I have a feeling it has something to do with my enemy looking for a player after the player dies.

Today, I got the homing missile completed, and then a decent amount of my boss enemy scripted out. I still need to add a couple of things to my boss, such as a couple of other abilities and that should be about it. I have the movement sorted out, and pretty much have the boss’ main ability finished. I just need to figure out some weird instantiation happening at the moment.

For the homing missile script, I came across some very interesting ways of scripting it. First off, I decided to utilize the move.towards function (Thanks Ryan for showing me this yesterday). This is a simple way to get your missile to fly towards an enemy. After getting this up and running, the next problem was the enemy would seem to get very confused if the screen was flooded with enemies. So the next idea that popped into my head was, “how do I find the closest enemy.” I tried using a distance function but this still would confuse the laser if there were multiple enemies within the distance.

After some googling, I came across some awesome scripts, in the Unity api, that lead me right where I needed to go. It looked a bit complicated off the bat, but after sitting down and dissecting the code it really wasn’t that bad. Basically you would use a Foreach loop and compare all the enemies in the array. The loop, one by one, compares all the enemies to find which enemy is the closest.

The next issue I had with the missile was that it could still miss the enemy, which is fine, but the problem was that if the missile missed it would stop in place and just sit there for a bit looking very confused. My next step to counter this, was to implement a simple coroutine selfdestruct routine. So after about 1.5 seconds the missile would destroy itself. And this also takes care of the problem if no enemy is around and the missile is fired, now the missile won’t forever be flying off into the distance and using precious memory.

--

--