Phase I — Progress report — Bomb powerup

Luke Duckett
2 min readMay 2, 2021

--

This update is going to discuss the implementation of the new powerup I’ve added which is the bomb.

The bomb attack moves up the screen slowly and kills the first enemy it collides with. This then creates an explosion of shrapnel which damages any enemy within range.

The issue with this powerup is how strong of an effect it is so I had to implement a weighted spawning system so I could give this powerup less chance of spawning. In order to keep the script modular, I added an interface called ISpawnable (I will discuss interfaces in a future article). The interface when implemented forces the object to use a property called “Spawn weight”.

In the spawn manager, we added some modularity so we can pass in any game object array and return the object to spawn based on it. Using the interface we can take the spawn weights off all the objects in the array and add them to a total weighting variable. We then randomly pick a number between 0 and the total weighting amount (plus one as in random.range the maximum amount is exclusive for ints) and iterate through the list until the amount is less or equal to the current object's weight.

--

--

Luke Duckett
Luke Duckett

Written by Luke Duckett

🎮 First Nations Unity Dev from Wonnarua country 🏞️ | From Player to Lifelong Learner: Crafting Games, Debugging Code, and Embracing New Technology

No responses yet