Daily progress: Day 1-2, Ammo Pickup.

Adding in an Ammo Pickup.

Rose Owen
3 min readJun 13, 2021

Ammo Pickup:

First, I was going to set up the functionality for the ammo pickup then work on the visuals. On the player script, I added a method to be called when you get the ammo pickup. This one was pretty simple, making the ammo count = 15, making it refresh the ammo count. If I wanted to make it so it has a higher ammo count, changing it to += then a number would be better off. After that, the UI for the ammo count was updated and the method was done.

Now to call this from the powerup script. Since we are using a switch statement we can just add in a new case for the ammo.

Lastly before working on the visuals for the pickup, making the prefab for the pickup animation when it’s ready.

Started by making an empty game object to store all the components for the pickup. Next, added all the components for the pickup, the Powerup script (add the Powerup sound, and set the Powerup ID to 3), A 2D Rigidbody (making sure to turn off gravity), 2D Box Collider (Setting it as a trigger), and lastly a Sprite Renderer (we can leave this empty for now).

At this point, it was really late so I ended up getting some sleep. After getting up again I started back on working on the visual part.

Since I didn’t have any animations set up for the Ammo Pick up, I took the speed animation and changed it to give the same look.

Before and after.

Using the side of the O to make the step down for the M and changed the Hue of the main color to give it a new look. After getting the Ammo lined out, I went through each frame of the speed animation and put the ammo that was made on the first frame then changed the color to match. Easy work just took time.

With all the frames done, next was to import them back into the project, using the first frame for the Sprite Renderer then setting up the animation

Final result.

After finishing the Ammo Pickup, turn it into a prefab and add it to the PowerUp Array.

Extra Life will be getting added next, stay tuned!
After a little test, things are working as expected!

And with that, another feature is added. Next time I will be adding an Extra Life Pickup, when picked up it will repair the ship of 1 state of damage until it’s fully repaired. See you there!

--

--