Spawn Negative Power-up

Niraj Karki
2 min readJun 3, 2021

--

Day 42- Making 2D Space Shooter Game

Objective: Spawning negative power-up which will have negative effects to the player.

First we need to spawn the negative power-up and we want it to be as rare as the health spawn.

So I created a condition to generate either health power-up or a negative power-up in coroutine in certain interval.

So when the player takes the negative power-up, this case will call the NegativePowerup public function inside of Player script from the Powerup script.

You can check out my creating power-up article to know how to create a power-up in unity.

Now inside Player script create a function which will disable shield if active and if not it will deal damage or it will decrease the player speed by half.

We also don’t want to keep player speed at half state for rest of the game so we are creating a coroutine to return the player speed to normal after 5 seconds.

--

--

No responses yet