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.
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().
Next we should adjust the damage animation since our lives might jump from 3 to 1, we need to make it more reasonable.
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.
All done! We can taste the poison now!
Next: What a Tricky Enemy!