Learn to code by making 2.5 D Space Shooter Game.

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.

--

--

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
Suleiman Abdullah

Self taught Unity Developer, who is passion about making games ,and he loves Math For Game Development