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:
- Create a gameobject with all the needed components.
- Make this as a powerup prefab.
- 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.
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().
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.