NOT THAT ONE!
Adding a Negative Powerup
In the last article, I Implemented a wave system allowing for multiple waves of increasing enemy numbers. Today, I’m going to be continuing the second, and final, phase of the GameDevHQ 2D Game Development Certification track. In this article, I’ll be implementing a new powerup that has a negative affect on the player when collected! The requirement reads as follows:
- Create a powerup that negatively affects the player.
Create and Import the sprite assets
Like with the other Powerups I’ve created before this, creating a new powerup required some new graphics to be created. I, again, took the existing sprites for the shields powerup into photoshop, changed the text to read “HAZZARD” and shifted the colors with a filter. Then I re-exported them and imported them into my project under their own folder.
Create the Hazzard Collectible Game Object
I follow the same process that I did with the other collectibles to create the Hazzard collectible game object. I select all of the imported sprites and drag them into my hierarchy window in the project Unity to create a new animation and GameObject at the same time. Then, I add a CircleCollider2D and a Rigidbody2D for pickup collisions. I also add a new value to the PowerupType enum for hazard.
Next, I add the Powerup script to the object and set the power up type to the newly added “Health” powerup type. I also set the Powerup Duration to 0 seconds since this powerup’s effect is instant. At this point, I prefab the object by dragging it into my Resources > Prefabs > Powerups folder.
Player script modifications
Lastly, I add the new powerup type to the players switch case that processes powerup collection and call the Player’s Damage function.
That’s it! My game now has a negative power up that damages the player when collected.
In this article, I implemented a new powerup that has a negative affect on the player when collected. Next time, I'll be adding a new enemy type! If you enjoyed this article, or want to come along with me as I progress on my journey, follow me at gamedevchris.medium.com.