Objective: Make ammo spawns more frequent and health spawns more rare

This will make the health packs and other powerups spawn with a 10% chance and the ammo spawn with a 30% chance. Since other powerups are special they shouldn’t show up as often as the ammo does.

Implementing this is fairly straightforward. First, I needed to learn about Random.value which gives a decimal value between 0 and 1.

Then, in the spawn manager script, we generate a random value. Assign all the possible values to our powerup ID values, going by increments of .1, which is 10% when converted to percentage.

--

--

Objective: Make sure the enemy lasers don’t fire after the enemy is destroyed

When the enemy is dead, it still occasionally will fire its weapon. This obviously shouldn’t be happening, so let’s fix it.

First, like any problem, we have to recognize it as we have.

Next, let’s take a peak at the enemy script and see what is going on.

There is a small delay when the enemy dies to allow the explosion animation to play before the game object is destroyed.

--

--