Road TO Dev — Let’s spawn some powerups!
Ok so we’ve made a couple power ups now let’s add them to the actual game by having them spawn in. As the name suggests we will be jumping onto our spawn manager for this. First we need to create a handle on our manager to know what powerups to spawn. There are a few ways to handle this but I am going to use an array here because I will always control the length and don’t need it to change.
We can then add the powerups in the inspector to the spawn manager
Now that we have this set we can create our powerup spawn routine.
We can reuse the same spawn logic as our enemies here for the area to spawn in so we don’t have to figure that out again. However we need to setup a way to randomize which powerup to spawn and can probably have our powerups spawn a little slower than enemies.
With this random range in our array we should have a 50/50 chance of spawning Tripleshot or Speed every 6 seconds. If everything is setup correctly it should look like this. Keep in mind we haven’t given our speed powerup anything to do just yet this is just to test the spawning.