Quick Start 4: Triggered Spawners & Custom Events

Picking up where we left off in Quick Start 3, in this one we're going to see how Triggered Spawners work, and take a quick tour of Custom Events, which we'll use to start the Wave of the Triggered Spawner.

     
  1. Triggered Spawners are a Component you can add to any Game Object that have Waves with mostly the same Wave Settings as Syncro Spawners, but Triggered Spawners do not care about Global Waves. Instead, they start their Waves from a wide variety of MonoBehaviour events, as well as Core GameKit's Custom Events.
  2.  
  3. To begin, create a new empty Game Object in the Scene called "TrigSpawner". Move it to a different position than your Syncro Spawners. Then add a Triggered Spawner V2 component to it from the Inspector. You should see something like this:
     

  4.  
  5. It starts with no Wave Settings, as the yellow warning tells you. Waves in Triggered Spawners are specific per "event", whether that be Trigger Enter on MonoBehaviour or Core GameKit Custom Events. We're going to show how to do the latter. So go ahead and select "Custom Event" from the "Event To Activate" dropdown and a new Wave setting will be added to the Inspector. It will look like this:
     

  6.  
  7. Luckily, the Wave Settings for Triggered Spawners are mostly exactly the same as Syncro Spawners, so we don't need to explain them again.
  8.  
  9. There are a couple problems with our default settings, as shown in red alert boxes. First, there's no prefab to spawn. Let's just use the Cube we already set up. Drag it in the "Prefab To Spawn" field. Let's make a couple other quick changes:
       
    • Change Min To Spawn to 4
    •  
    • Change Max To Spawn to 4
  10.  
  11. Let's use the Randomization option this time. Check the "Randomization" checkbox to expand that section. It looks like this now:
     

  12.  
  13. Click and drag the "Rand. Distance X" & "Rand. Distance Z" fields and watch in Scene View as it previews the wave. Very cool! I've settled on 6 for X and 3 for Z.
  14.  
  15. The 2nd problem with the Wave is that we haven't chosen a Custom Event from the dropdown up top. Actually we won't be able to since we haven't created any yet. Let's create a Custom Event now.
  16.  
  17. Go back to LevelWaveSettings by clicking on the Core GameKit logo. Now scroll down to the "Custom Events" section and expand it. It will look like this:
     

  18.  
  19. To create a Custom Event, just fill out the "New Event Name" (let's call it 'Spawn Random Cubes') and click "Create New Event". It will show up as a row in the blue Category below. We aren't going to do any fancy Custom Event options so let's just leave it as the default settings.
  20.  
  21. Now we need to go back to TrigSpawner and select the Custom Event we just created. So select TrigSpawner and find your Custom Event in the "All Custom Events" dropdown and select it. The red error will disappear.
  22.  
  23. At this point, we could test the Triggered Event by pressing play and clicking "Fire!" next the the Custom Event row in LevelWaveSettings. But let's get it firing for real.
  24.  
  25. Go back to LevelWaveSettings and open the Levels & Waves section. Scroll down to the Global Wave for Level 1, Wave 1.
  26.  
  27. Scroll down and find the section "Wave Completion Custom Events" and check it to expand the section. This is used to specify Custom Events to fire when the Wave is compleed. It will look like this:
     

  28.  
  29. Click the "Add" button, then select your Custom Event from the "All Custom Events" dropdown.
  30.  
  31. We would be done except that by the time (the next frame) the Triggered Spawner will be spawning its wave that listens for the Custom Event, "Game Over" will be true so it will not spawn anything. There's a way to change this default behavior though.
  32.  
  33. Go back to TrigSpawner and change "Game Over Behavior" to "Behave As Normal". Now it will spawn the Wave regardless. If you press play, you can wait for the Global Wave to spawn everything as before, then despawn it all with Pool Boss. Do it 2 more times for the Wave Repeats. At that point, you'll see your Triggered Spawner spawn its Wave as the Custom Event is fired.
 

That's it for this Quick Start!

 

Next: Quick Start 5: Killables & World Variables