2D Galaxy Shooter: It’s shaping up into a real game!

Gabriel Perez
2 min readApr 8, 2021
Triple Shot Activated!

With the implementation of the power-up system, I can now collect a power-up!

The first power-up is a triple shot. The name says it all. It shoots three lasers for extra firepower for use in sticky situations!

While setting up the power-up, I used Unity’s animation system to animate the triple shot power-up collectible.

I’m using the animator's dope sheet to animate the 2D sprite frames of the triple shot power-up.

To make it work so that the player can pick up the power-up, I created a power-up script and attached it to the triple shot powerup prefab. I want the powerup to detect when the player collided with it. So in the OnTriggerEnter2D() function, I check to see if the player collided with the powerup. And if it did, I then want to communicate with the player script to have access to a function that activates the triple shot to true.

Activating the power-up by colliding with it.

This function calls TripleShotActive() in the player script and activates the power-up. It also calls a coroutine that powers down the power-up after five seconds.

public void TripleShotActive()
{
_isTripleShotActive = true;
StartCoroutine(TripleShotPowerDownRoutine());
}
private IEnumerator TripleShotPowerDownRoutine()
{
yield return new WaitForSeconds(powerDownTime);
_isTripleShotActive = false;
}

With everything working in harmony, the game is looking polished as I continue to go through each section of the course.

In the next update, I’ll have a couple of more power-ups!

Thank you for reading. :)

--

--

Gabriel Perez

Hello everyone, My name is Gabriel Perez, I am a Unity Developer and a creator who is always learning and experimenting.