Is That a New Buff? No, It’s a Debuff - Negative Collectible!

Matej Marek
3 min readMay 13, 2021

It is time to mix things up in the power-up world! Right now, the player would tend to pick up any power-ups coming his way without really thinking about what they might be picking up; let’s change that!

An active ‘Hazard’ “power-up.”

Objective

Add a new power-up to the game - but instead of buffing the player, the player gets an active debuff for a couple of seconds.

Implementation

I have decided to go with double factor debuff:

  • Invert the direction of the player movement.
  • Increase the fire rate between the shots so that the player will not be able to shoot as often.

First up, we will need a new GameObject - the ‘Hazard’ “power-up”.

Animation done by Kyle Powers.

With this done and ready, we will have to make a few changes to the code by increasing the number of different power-ups to spawn.

‘SpawnManager’ script update.

Next, set an activation in the ‘Powerup’ script.

And finally, adding the behavior in the ‘Player’ script. Here, we will need a few new variables. These variables will be used as an adverse effect, and of course, we will need a bool to check whether the effect should be active.

Next, we create the public method we call from the ‘Powerup’ script- ‘DebuffPlayer()’. This method will start a Coroutine that will change the behavior of some other of our methods for the duration of the debuff.

Now, we need to update the ‘PlayerMovement()’ method with a simple if statement.

And similarly, the ‘Fire()’ method as well.

And that is it! Now the player has a new danger to watch out for!

But that is it for now, thank you for reading and feel free to follow me for more articles - and as always, good luck and see you next time!

--

--