To script or not to script.

KT
2 min readDec 10, 2020

--

Today I continued to work on the homing missile. I found a cute rainbow Mario star .png file and I converted it to a powerup by adding a 2D rigid body and a 2D circle collider.

Then I started working on the spawning. The instructions state that this powerup needs to spawn rarely. I also looked ahead into Phase II (which I’ll be tackling next) and saw that an assignment in there requests that our current random spawning be converted to “smart spawning” (my words) so that very powerful powerups like health and this homing missile spawn rarely and more needed items like ammo spawn regularly.

My first instinct was to create a new spawning script with a longer spawning interval. I created the new script and did not feel comfortable with it as it was identical to my current Powerup script with only the interval of time different. This can’t be efficient (I thought) and so I decided to just change the time intervals on the original spawn manager for the rare powerups. So I deleted the new script and started modifying my original spawn powerup script. Low and behold, after adding much more code that I had anticipated, I saw just how clunky my code was and realized that a second script for the rare powerups would, after all, be much more straight forward end efficient. So I’m at the point now of having to revert my code to it’s original form and go ahead and add and integrate a new script for the rare powerups.

New homing missile power up.

Here is what I have so far with the homing missile powerups spawning randomly like all the others.

--

--