Repair Your Ship- Game Dev Series 37

S.J. Jason Liu
2 min readJun 1, 2021

--

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.

--

--

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.