Journal 37 — Negative Power Up in Unity
In this article, I updated one of the power ups and changed it to a negative effect.
The concept in this case is to use a Speed Up power up, but change it slightly to make it greatly affect and reduce Player movement.
To start, we can take the basic Speed Up power up, and modify it slightly to make it a little deceiving while collecting power ups in the middle of a game.
Next, we can update the switch statement in the Powerup C# script to add an additional power up option.
Over in the Player C# script, we can add the function to start the negative speed impact. We will use some bool variables to make the negative speed true, and also make sure the thrusters are disabled in order to really impact the player.
In the Player’s movement function, we will update speed and thruster conditional statements and loop through the conditions whether speed up is true, or negative speed is true, or whether the player can use thrusters.
In order to spawn the negative speed power up, we need to update the SpawnManager script. I used a random number generator with a few conditional statements depending on the power up for each spawn, with some conditions that spawn a more basic power up (e.g., speed up, triple shot), to a more rare special attack power up, and the last power up is the negative speed we just created, for powerUps[6].
Finally, we can see the big impact in Playmode.
Thank you for your time!