Nerd For Tech
Published in

Nerd For Tech

Space Poison Incoming!- Game Dev Series 43

Objective: Create a negative powerup in game.

Powerups should not always be good. When the player is in busy, negative powerup should be a trap to distract player gets more hurts.

In this article, I will skipped the prefab creating part which would be the same in some previous articles. We will jump to the coding and adjust some existing scripts.


We should figure out what is the effect of poison? As a negative powerup, I will make our player gets double damage when poisoned. Even more, it will disable the shield protection, too. With that idea, we should be ready to coding now.

In Player, we will create a public method to dealing with poison. First, we will need a bool. With the bool, we can create a 5 seconds long effect as we get poisoned.

And also add 2 lines in this method to disable the shield.

Then we can set the poison effect in Damage().

Kinda brutal…

Next we should adjust the damage animation since our lives might jump from 3 to 1, we need to make it more reasonable.

In this adjustment, both left & right damage animation will active when the lives is 1.

Next, we can set the powerup ID.


All we need to do in this script is to create another ID case in switch statement.

And don’t forget to add the poison prefab and setting the ID in editor.

Next is the spawning rule of poison.


We should make the spawning frequency of poison is lesser than others. To do that, we will need an integer variable to do the counting.

Create an int variable inside the SpawnPowerupRoutine().

We can set a random range to randomize the spawning time of poison. Then spawn it in a if statement. In this statement, poison get spawned when the count is greater than the randomize number.

When we spawned a poison, we can clear the counting of normal powerups.

However, with this if statement, we might spawn 2 powerups at the same time. To prevent that, we can combine the firework shot statement and others into one statement.

Don’t forget to add 1 to normal powerup count in the last line.

All done! We can taste the poison now!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.