Learn to code by making Space Shooter Game
Objective: Implement Triple Shot Powerup

In order to do this we need to add our triple shot Power up Sprite to the hierarchy then resize it don't forget to add collider and Rigidbody 2D.
Then we need to create Powerup script and attach to our TripleShotPowerup sprite.

Now lets add Powerup Behavior to move down TripleShotPowerup at speed of 3 unit per second inside Powerup scripts.

We need to give illusion to a player that we collect a Powerup when we collide with Player we destroy Powerup Game Object .
We do this by add OnTriggerEnter Method to check which gameObject collide with us , if it Player destroy us Other wise do nothing.

This is a time to enable Triple Shot , we need to create a method inside player to activate TripleShot .

Now we need to call this method when we collect TripleShotPowerup , In order to do this we need to communicate with player so first lets create a reference variable of Player type then Find GameObject get component in Start method .

The best Practice of using GetComponent is to null check to avoid NullReference exception .Then lets use our player reference to activate TripleShot.


Thank you for your time see you next article
Suleiman.