Adding a negative pickup item to my space shooter
Powerups are great! They *up* the players *power*. But, what if some of them didn’t? I have to punish my player right? Just nod your head in agreement and I’ll stop doing this weird bit.
I want to add a pickup item that damages the player if they collide with it, even if their shields are up. To do that, I created a new prefab object with all the same components as the powerup prefabs, but I replaced the powerup script with a unique script for negative pickups. It works the same way, but I want to tailor the logic to the negative pickups. For example, I lowered the speed of the negative pickups so they stay on the screen longer and become more difficult to avoid. I only have one pickup for now, and it will be calling a method in the Player script to cause damage. RemoveHealth() is being called from the pickup script.
I also need to create a new spawning routine for the negative pickups because I want them to spawn a little less frequently. I’ll duplicate the existing powerup spawn logic and modify it slightly. It waits for 2–5 seconds before starting to spawn, then spawns pickups every 9–12 seconds.