Ok, so I want to create a wave system of enemies. These enemies spawn from 1 game object and they have a unique pattern. It’s not just random enemies spawning at the same speed, but rather a series of enemies that inherit the same pattern. Let’s look and see how we can build this.
First, I want to create enemy. I will use the animator to create 1 enemy with a flight path. 2 important points when you create this:
- You have to make sure you place the item you are animating at the 0,0,0 point of a parent game object
- You animate the child and then reposition the parent
- You cannot move the object with the animation — that’s baked into world position. You have to instantiate the parent.
After we create the enemy animation, let’s put the wave spawn system together. This system will spawn x enemies over at a x rate. So let’s attach the enemies, spawn positions, and total enemies spawned and the rate. We also need to make sure we know how many enemies we’ve spawned thus far.
Then we have to create the spawn system. So when we turn on this game object, the enemies will spawn at a consistent rate over time until it hits a final value. Then it will stop instantiating enemies.