One of the issues I mulled over a bit ago was how to differentiate *which* asteroid has a powerup and which doesn’t, so the player can scoot on over to target one that does instead of randomly hope it contains a powerup.
In the very original pre-alpha version of the game (called Graviton back in 2008/2009), I used simple geometric primitives to display the objects (thus, an asteroid was merely a circle). I inscribed a smaller white circle in those to indicate a powerup is contained in said asteroid. This time, however, I figured a more interesting way would be to use the power of Unity’s built in TrailRenderer system. A very handy feature that allows you to set up “trails” (insert LSD joke here) on objects, and the system takes care if it all for you (well, drawing and stuff, you have to make sure to enable it at the right times and such).
So, I got that feature going well enough. Currently I only have the “autofire” powerup spawning at a given time (black hole radius = 5, for those who are curious).
At first I thought all I had to do was work on incrementing the powerup and the spawn trigger rule. But I forgot one thing. I have to reset/delete the “autofire” powerup from the original asteroid. Since everything is recycled (for memory efficiency), it means that when I respawn the asteroid that contained the autofire powerup, it still contains it, as I didn’t actually remove it from the asteroid. This in theory shouldn’t be too hard, but you never know. I think it’s simply a boolean or an int that indicates the powerup (I’d have to look at the code but it’s all closed out now). Then when the asteroid is “destroyed” (recycled to the asteroid pool of objects), I just reset that information so it looks as though it contains nothing.
Anyways, I’m pleased that I got this done within a couple hours of awaking 🙂 Tired as hell, need some coffee, but at least it’s a nice start to my day…