Common Collectables

Matthew Bartosh
2 min readSep 26, 2022

Today my objective is to create what I’m calling “Common Collectables”, health and ammo that will be handled separately from my ‘powerups’, but I’m going to make health rarer than ammo.

I’m setting up the variables in the SpawnManager.cs first, then adding StartCoroutine(HealthAndAmmoRoutine()); to my StartSpawning method.

Here’s a look at that coroutine, rolling a float between 0 and 1, spawning a health collectable if it’s under .25 and an ammo collectable otherwise.

Next I’ll be adding case 3 and case 4 to my _powerupID switch.

Which then leads right into Player.cs and the AmmoRefill() and HealPowerup() public methods.

This will disable the visual damage and update the lives UI when the Player picks up the heal. I don’t have icons for these pickups that match the others, so I acquired some from online (shout out to craftpix.net). I might commission a friend to create me matching icons for every pickup I will eventually have.

Tomorrow I’m adding a brand new weapon pickup! Swing by next time to check it out.

--

--