Journal 19 — Modular Powerups, Unity Practice
As part my game development, we have added two power ups, and I getting close to add a third. If you recall, we have a spawning function for power ups that is currently written only for the tripleshot.
To make the function modular, such as if we wanted 5 or 10 different power ups over all the game levels, we can use an array to store all the power up game objects.
In the example below, we add a new array GameObject powerUps, and show it in the Inspector. From there, we can specify the size in the Inspector (three total power ups for now), and delete the other individual game objects.
The spawn fuction for the power ups is modified using a random integer for 0, 1, and 2 to instantiate the power up randomly.
Finally, we can test the gameplay to see if the power ups randomly spawn and drop to collect.
Thank you for stopping by!