Quick Start 3: Prefab Pools

Picking up where we left off in Quick Start 2, in this one we're going to create a Prefab Pool so our Spawner doesn't just spawn the same exact prefab, but random weighted prefabs instead. This is actually very easy.

     
  1. To create the Prefab Pool, click on the "Prefab Pools" button in the Core GameKit logo up top in our Inspectors. You'll see an Inspector like this:
     

  2.  
  3. Just set the name (let's keep the default for this one) and click "Create Prefab Pool". Then you'll see a row for the new Prefab Pool, shown below:
     

  4.  
  5. Notice that the row says the Prefab Pool has 0 items. So it won't be usable by a Spawner until we add some items (prefabs). Click the gear icon so we can edit the Prefab Pool. It looks like this:
     

  6.  
  7. Normally, random prefabs is what we want, so let's keep the "Spawn Sequence" dropdown at the default selection. We just need to drop in a couple prefabs. Go ahead and create a Capsule prefab and a Cylinder prefab (make sure to remove them from the Scene too), then return here to this Prefab Pool's Inspector.
  8.  
  9. Now, you just drag the prefabs you want items for into the yellow drag area. It will create items for each. You should have something like this now:
     

  10.  
  11. As before, make the Pool Boss errors go away by deciding on a Preload Qty and clicking "Create Pool Boss Item". Let's do 20 for each.
  12.  
  13. The last remaining thing to do is decide on "Weight" for each item. The Weight is how often the item will be picked relative to the other item Weights. So if we put a Weight of 2 on the Cylinder and a Weight of 3 on the Capsule, that would mean the Cylinder would spawn 40% of the time and the Capsule 60% of the time. If that wasn't clear, to get the percentage, you divide the items' Weight by the total of all Weights (i.e. 2 / 5 = 40%).
  14.  
  15. Now our Prefab Pool is ready to use. Let's go to Spawner1 and use it there. You'll find it in the Hierarchy under LevelWaveSettings / Spawners / Spawner1.
  16.  
  17. Down in your Level 1 / Wave 1 Spawner Wave, the Prefab Type dropdown is set to "Specific". Change that to "Prefab Pool" and then select your Prefab Pool "EnemiesPool" from the "Prefab Pool" dropdown under that. It's now going to use the Prefab Pool when spawning. It should look like this now:
     

  18.  
  19. Let's make the Wave Repeat as well. Scroll down to the "Repeat Wave" section and check it so it opens the section. It looks like this:
     

  20.  
  21. We'll just make a couple changes:
       
    • Change "Repetitions" to 3.
    •  
    • Change "Time Increase" to -2. This will mean that for each repeat, the "Time To Spawn" is reduced by 2 seconds, so it will spawn the Wave faster and faster, like a swarm.
  22.  
  23. Go ahead and press Play now. Watch the Waves until they are fully spawned, then use Pool Boss to despawn everything as before. At that point, since the Spawner 1 Wave is eliminated, it will start its first Wave repeat (since its Global Wave is Elimination, the Spawner's Wave repeat will wait for elimination).
  24.  
  25. After the Wave repeat is fully spawned (and faster to do so), use Pool Boss again to despawn everything. The 2nd Wave repeat will start.
  26.  
  27. After the Wave repeat is fully spawned (again faster), use Boss to despawn everything again. At this point if you look at the Game Status Panel on LevelWaveSettings, you will see the Global Wave is complete and therefore "Game Over" is true. To be clear, when we set "Repetitions" to 3, that means 3 including the initial Wave (+ 2 repeats).
 

That's it for this Quick Start!

 

Next: Quick Start 4: Triggered Spawners & Custom Events