Journal 39 — Change Balance of Spawn Power Ups in Unity
This article is about a modification to the probability of what power ups spawn.
The earliest version of the spawn function for power ups consisted of a random value generated based on the ID, which would spawn the power up directly.
I expanded this spawn routine with all the power ups in game, and used a random number generator at the start of each spawn cycle. After this condition is passed, I then used a similar approach as above with selection of the power up using the power up ID in condition statements. Essentially, this approach adds a weighting factor that favors the spawning of more basic power ups [0] through [4], and makes it rarer to spawn the special attack [5] and the negative power up [6].
The final version of this approach expands this weighting function so that all of the seven power ups can be customized by the user to a preferred rate of spawning. In this version, a health power up and special attack are the rarest.
Thank you for stopping by!