Repair Your Ship- Game Dev Series 37

Objective: Create collectable repair powerup gameobject.

In this article, we will create another powerup to repair our Player.

There are 3 steps we need to complete:

  1. Create a gameobject with all the needed components.
  2. Make this as a powerup prefab.
  3. Activate it in code.

Create gameobject with needed components.

As usual, drag in the sprite of our repair powerup in to Hierarchy. Add necessary components to it.

And also create the animation to make it alive!

Create a prefab

Once all the setting is done, drag it back to Project as a prefab.

Activate it!

Now we can start to activate it.

Open the Player script, we need to create a public method to change the live counts with powerup.

We’re not only update the live counts and UI, but also update the damage sprites.
Therefore, we need to extract the damage visual effect switch statement as another method: DamageSprites().

In this method, we need to turn the effects on and off on specific statement.

Then we can call the AddLives() method in the Powerup script.

Our AddLives() now should assign 4 as its PowerID.

All done! Now you will be fixed during the game.



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