Objective: modularize Powerup scripts to allow all powerup to use the same scripts.
In order to do these we need to add Speed Powerup sprite, resize it and add all necessary component to work finally .
we want to have at least 2 Powerup to see the result with Powerup script attached.
The first thing is to add PowerupID inside Powerup scripts.
Lets add powerupID to each powerup in the inspector window.
Now we need to activate Powerup behavior by checking which PowerupID it is.
Its time to Increase Player Speed when we collect Speed Powerup , lets jump to Player scripts and add a method to increase speed when we collect Speed powerup.
We need to call this method when we collect speed powerup
This will make our ship run faster forever if we collect Speed powerup , we need to add a cool down system to our ship speed.
Note : Remember to call coroutine in activateSpeedBoost for coroutine to work.
This is how we modular a script , see you in the next article.