Triggered Spawners

In addition to the Syncro Spawners, there are Triggered Spawners. This type of Spawner does not care about the Global Waves set up in LevelWaveSettings. Waves in this type of Spawner are triggered by various MonoBehaviour events such as OnBecameVisible, OnCollision, etc. You do not create these Spawners from LevelWaveSettings. It is a script you can add to any prefab. You do so from the Component menu under Dark Tonic -> Core GameKit -> Spawners -> Triggered Spawner V2 (Triggered Spawner V1 will still be here for some time to allow users to migrate without losing settings). You simply choose an event from the "Event To Activate" dropdown and it will then be used as long as the checkbox for that section is checked.

 

It looks like this:

 

 

There are 2 sections of controls:

  1. Top Section: Settings that apply to the Spawner itself.
  2. Wave Settings: Settings for each Wave in the Spawner, which are per event.

Top Section

 

Most of these settings are the same as the ones in Syncro Spawners, but we'll repeat them anyway.

     
  1. Inactive Alert: At the very top of the Inspector just below the Core GameKit logo, a large red bar will appear to let you know if the Spawner is inactive because it's despawned or disabled because of the Wave Pause Behavior or Game Object behavior. It looks like this:
     

  2.  
  3. Active Mode: This controls when the Spawner is active. There are four choices:
       
    • Always: The default.
    •  
    • Never: Disable the Spawner entirely.
    •  
    • If World Variable In Range: This lets you define a range for a World Variable value that must be satisfied for the Spawner to be active. For example, the Spawner will be active if your experience points is between 1000 and 2000.
    •  
    • If World Variable Outside Range: Opposite of "In Range". This will let you not have to worry about upper limits. For example you could say a Spawner is active if outside the range of 0-1000 XP. So it will start to show up after you reach 1000 no matter how many experience points you get.
  4.  
  5. Spawn Settings: Some controls about behavior that applies to all prefabs you spawn with this spawner are located here.
       
    • Spawn Outside: Check this if you want the items spawned to have no parent in the Hierarchy. Otherwise they will spawn as a child of the spawners. If selected, additional controls appear:
         
      • Spawn Follows Spawner: Defaults to off. If you turn this setting on, the spawns will follow the spawner, updating its position every frame.
      •  
      • Spawner Disabled Behavior: Defaults to "Do Nothing". You can also choose "Stop All Particles", which will stop emitting particles from the spawn when the spawner is disabled or despawned.
    •  
    • Spawn Layer / Tag Mode: These let you control what Layer / Tag the spawns take on as they are spawned. 3 choices:
         
      • Use Spawn Prefab Setting: Keep the prefab's Layer or Tag.
      •  
      • Use Spawner Settings: Use the Layer or Tag of the Spawner itself.
      •  
      • Custom: Specify any Layer / Tag you like, choosing it below.
           
        • Custom Spawn Layer / Tag: Pick the Layer or Tag you want here.
      •  
      • Apply Layer Recursively: this appears in some Spawn Layer Modes and lets you apply the selected Layer to all sub-Game Objects as well.
  6.  
  7. Master Audio Sounds: This section only visible with Master Audio integration because it uses Master Audio.
       
    • Item Spawned Sound: This plays a Sound Group of your choice when an item is spawned.
    •  
    • Item Failed To Spawn Sound: This plays a Sound Group of your choice when an item fails for spawn.
    •  
    • Wave Finished Spawning Sound: This plays a Sound Group of your choice when a wave finishes spawning.
    •  
    • Wave Start Sound: This plays a Sound Group of your choice when a wave starts.
    •  
    • Elim. Wave Completed Sound: This plays a Sound Group of your choice when an elimination wave is completed.
    •  
    • Wave Repeat Sound: This plays a Sound Group of your choice when a wave repeats.
    •  
    • Spawner Despawning Sound: This plays a Sound Group of your choice when the Triggered Spawner is selected to Despawn at the end of a wave and does so.
    •  
    • Spawn Sound: This plays a Sound Group of your choice when this spawner is spawned.
    •  
    • Despawn Sound: This plays a Sound Group of your choice when this spawner is despawned.
  8.  
  9. Game Over Behavior: This setting allows you to choose whether the Spawner continues to function when "Game Over" is true. Choose "Behave As Normal" if you want this, otherwise it will disable.
  10.  
  11. Wave Pause Behavior: This setting allows you to choose whether the Spawner continues to function when Global Waves are paused. Choose "Behave As Normal" if you want this, otherwise it will stop spawning.
  12.  
  13. Unity UI Version: You can select whether you're using Legacy UI events or uGUI. This will filter out the choices for the other from the Event To Activate dropdown.
  14.  
  15. Child Spawner Settings: You can set up the Triggered Spawner to have Child Spawners. I will just mention the settings here for completeness and you can click on that link to read more.
       
    • Trigger Source: 3 choices:
         
      • None: This basically disables the Triggered Spawner. This can be used for testing purposes or to disable Child Spawners without deleting them.
      •  
      • Self: The default setting. Events will be triggered as normal like a Parent Spawner (or Spawner with no Child Spawners) should.
      •  
      • Receive From Parent: The setting to use for Child Spawners. All events on the Child Spawner itself will not cause any waves to be spawned, but when the Parent Spawner has those events occur, the Child Spawner will be notified to follow suit and also spawn its Waves of the same type (i.e. Visible).
    •  
    • Propagate Triggers: Only visible for Child Spawners. This checkbox (only visible when your Spawner has Child Spawners under it) controls whether or not to trigger the Child Spawners. If you uncheck this box, the Child Spawners will not spawn anything.
  16.  
  17. Log Missing Events: If checked, this will log an error to the Console if it is using Custom Events that don't exist in your LevelWaveSettings Game Object.
  18.  
  19. Listener: Here you can drag in a TriggeredSpawnerListener to hook into key events and do customized coding. For more about Listeners go here.
  20.  
  21. Event To Activate Dropdown: To add a Wave that is triggered by an event, select the event in Event To Activate dropdown. Then you will see the section added and expanded. All the settings will be visible. The settings for each section are mostly the same, but there are a few settings that don’t show up for certain event types because it would not make sense for them to be there, and would cause a lot of confusion to users tweaking it.
     

    The full list of events is as follows:

       
    • MonoBehaviour Events: Usable with no plugin requirement:
         
      • Enabled
      •  
      • Disabled

        Note: Enabled and Disabled can be fired by using an Activation Track in Timeline. When the Game Object is activated, the Enabled wave will spawn, and when deactivated, the Disabled wave will spawn.
      •  
      • Visible

        Note: Visible and Invisible will only work inside a prefab that has a Renderer Component on the same Game Object. In cases where batching will reassign or not use the Renderer (NGUI / 2D Toolkit, etc), you may opt to use the Enable / Disable events instead (or the Pool Boss events). They don’t provide exactly the same functionality but it will work for most purposes.
      •  
      • Invisible
      •  
      • Collision Enter
      •  
      • Trigger Enter
      •  
      • Trigger Stay
      • - For this event, you will specify "After Stay (seconds)", after which this wave will spawn.
         
      • Trigger Exit
      •  
      • 2D Collision Enter
      •  
      • 2D Trigger Enter
      •  
      • 2D Trigger Stay
      • - For this event, you will specify "After Stay (seconds)", after which this wave will spawn.
         
      • 2D Trigger Exit
      •  
      • Unity V1.0 - V4.5 Legacy Unity GUI Events:
           
        • Mouse Over
        •  
        • Mouse Click
      •  
      • Unity uGUI Events (all the uGUI events are only visible and usable if you put the Triggered Spawner Component on a Unity Component (which has a RectTransform Component):
           
        • Slider Changed
        •  
        • Button Click
        •  
        • PointerEnter
        •  
        • PointerExit
        •  
        • PointerDown
        •  
        • PointerUp
        •  
        • Drag
        •  
        • Scroll
        •  
        • UpdateSelected
        •  
        • Select
        •  
        • Deselect
        •  
        • Move
        •  
        • InitializePotentialDrag
        •  
        • BeginDrag
        •  
        • EndDrag
        •  
        • Submit
        •  
        • Cancel
      •  
      • Code-Triggered Events: These are meant to be only called by code you write, if you want to start Waves at times other that the events listed.
           
        • Code-Triggered 1
        •  
        • Code-Triggered 2
      •  
      • Pool Boss Events: Fired from Pool Boss:
           
        • Spawned (is the OnSpawned method)
        •  
        • Despawned (is the OnDespawned method)
      •  
      • NGUI Events: Fired by NGUI plugin only, if you have it:
           
        • OnClick
      •  
      • Core GameKit Custom Events: Each Triggered Spawner can be set up to receive 1 or more Custom Events with separate Waves defined for each.
  22.  
  23. Collapse All Events Button: Click this to collapse all the Events (waves for each) down to one line each.

Wave Settings

The settings for the Waves in Triggered Spawners are mostly the same as you have seen in Syncro Spawner Waves, with a few differences. Here are the settings for each Wave you create to respond to an event:

     
  1. Title Bar Controls: Buttons that do the following appear here:
       
    • "Fire!" Button: This appears at runtime in the Inspector for each Wave you’ve configured. You can click it to spawn the Wave without having to make the event happen naturally. This saves on testing time.
    •  
    • Delete Button: Deletes the Wave.
  2.  
  3. Visualize Wave: Checked by default. When checked, this will show you the spawned items in the Scene and Game view as you tweak the values (in Edit mode only) so you can see the shape of the Wave. When you hit play, the Game Objects created for visualization will be deleted during play mode and return when you press stop. Visualizing a Wave will uncheck the box for all other Waves in the Triggered Spawner. Items created for visualization purposes will have an eye icon on the far right in the Hierarchy so you know why they are there.
  4.  
  5. Wave Completed When: This controls when the wave is "completed" and a Wave Repeat would begin. 2 choices:
       
    • Items Done Spawning: The default.
    •  
    • Items Eliminated: This must be used if you want to wait for certain Triggered Spawner waves to be completed in a Global Wave. Also useful otherwise for waiting to repeat until everything spawned is gone.
  6.  
  7. Prefab Type: 2 choices.
       
    • Specific: The default. You will select a prefab to spawn.
         
      • Prefab To Spawn: This is the prefab you will be spawning copies of.

        Note: If you have not set up this prefab in Pool Boss, the following section will appear in the Inspector letting you do it without leaving the current Inspector, as long as the Category you want to add it to already exists. This is a time saver. Just create the Categories up front if you can in Pool Boss. Read more here.
         

    •  
    • Prefab Pool: You will use a Prefab Pool for a weighted group of prefabs instead of a single one.
         
      • Prefab Pool: Select one of your already created Prefab Pools from the dropdown. There is a gear icon to the right that you can click to navigate to the Prefab Pool and make changes.
  8.  
  9. Min / Max To Spawn: A random number between these two numbers will be chosen for how many of your prefab to spawn.
  10.  
  11. Time To Spawn All: This is the length of time it will take to spawn all of your prefab. So if you specify 20 for Min to spawn and Max to spawn, and 2 for Time To Spawn All, it will spawn 10 per second for 2 seconds. This will not be able to be set higher than the Wave duration in LevelWaveSettings. If you use Spawn Limit Controls, then think of this as the *minimum* time to spawn all, as the Spawn Limit Controls may make it take longer.
  12.  
  13. Delay Wave (sec): This is used to delay the Spawner wave later than the precise Wave change in LevelSettings. Just set this to how long you wish to delay the first spawn in seconds. Note that Wave Repeats do not use this to delay the repeated wave unless you check the next checkbox.
  14.  
  15. Use Wave Delay On Repeat: Check this box for Wave Repeat to also use the Delay Wave setting. Only visible if Wave Repeat is on.
  16.  
  17. Distance Type: Choose either Local or World. World is the default. Set it to Local to apply the randomization / incremental / offset settings taking into account the spawner's rotation.
  18.  
  19. Stop On Invisible: (or Stop On various Trigger events) - This lets you end a Wave when the opposite event happens. So for example you can end a "visible" Wave when the Game Object becomes invisible. Only visible where it makes sense and there is an opposite event.
  20.  
  21. Disable Event After: Check this if you want the event to only be able to happen once for this Spawner. For instance, only the first time a trigger is entered, it will spawn. The event (Wave) will be disabled after that Wave spawns.
  22.  
  23. Despawn This: This is a checkbox that shows up for certain events that is primarily to keep you from having to create a Triggered Despawner also when you want to do prefab replacement. So if you want your prefab to turn into an explosion when it has a collision, you simply check "Despawn This" and specify the explosion(s) to spawn, and you’re done. Note that the despawn will happen immediately, so if you've chosen a Time To Spawn greater than 0, it may not finish spawning items.
  24.  
  25. Layer / Tag Filter: These options show up only under Collision and Trigger Events. By default, all Layers and Tags will spawn the Wave you specify. These refer to the Layer and Tag of the other object you’re colliding or trigger-colliding with. How it works:
       
    • If you check the Layer Filter checkbox, you can specify which Layer(s) will trigger the Wave. All other Layers will not.
    •  
    • If you check the Tag Filter checkbox, you can specify which Tag(s) will trigger the Wave. All other Tags will not.
    •  
    • Tag and Layer Filters work together, so if you select a Tag that is never used by objects in the selected Layer filter, the Wave will never trigger. Most likely you will only use a Layer OR Tag Filter for a single Wave, but be aware of this.
  26.  
  27. Position Settings:
       
    • X/Y/Z Position Mode: Choose Spawner Position, Custom Position (type a Vector3) or Other Object Position (drag a Game Object in to use its position). Each axis lets you use a number, a variable or the Spawner's position for spawning.
    •  
    • Offset Selection: This controls how the Wave Offsets (next) are used by each successive item that is spawned. 2 choices:
         
      • Randomly Chosen: The default, will choose a random one each time.
      •  
      • Use In Order: Will cycle the usage of each, starting with the first, top to bottom.
    •  
    • Wave Offsets: This is a group of Vector3's. At runtime, these are chosen and added to the Spawner's position before any Incremental or Post-Spawn nudge settings. This will allow you to spawn from a different location than the Spawner. This respects the Spawner's rotation so X, Y and Z are actually Right, Up and Forward. This Vector3 gets added to the position created from the field above (X/Y/Z position mode settings). You can create any number of these.
  28.  
  29. Spawner Rotation Mode: This field only shows up for Custom Event Waves. It has 2 choices:
       
    • Keep Rotation: The default. Don't change the rotation of the Spawner when the custom event happens.
    •  
    • Look At Custom Event Origin: Using this option will make the Spawner turn to look at the event origin. Good to make enemies chase the player when he performs certain actions!
  30.  
  31. Spawn Rotation Mode: This has 4 choices (one more than Syncro Spawners have):
       
    • Use Prefab Rotation: The default. The prefab will be spawned with whatever rotation the prefab has itself.
    •  
    • Use Spawner Rotation: This will rotate the spawned prefabs to match the Spawner's current rotation immediately after spawn.
    •  
    • Custom Rotation: This allows you to specify a custom rotation of X, Y, and Z euler degrees. Spawned prefabs will be rotated to match this immediately after spawn.
    •  
    • Look At Custom Event Origin: (only valid for Custom Event Waves). This will spawn all Wave items looking at the event origin point. If you choose this Rotation Mode, you have the option to ignore specific axes X, Y or Z and use the spawner's X,Y or Z instead for the LookAt.
  32.  
  33. Spawn Scale Mode: This has 4 choices:
       
    • Use Prefab Scale: The default. The prefab will be spawned with whatever scale the prefab has itself. Note that if it's spawned as a child of the Spawner, the Spawner's scale will affect the scale of things spawned. If you are going to change the Spawner scale around, you will probably not use this option and might prefer "Percent Of Spawner Scale", below.
    •  
    • Use Spawner Scale: This will set the spawns to the scale of the Spawner itself.
    •  
    • Percent Of Spawner Scale: This will set the spawns to the scale of the Spawner itself times a percentage you specify here. Even though it's a percentage, it can be greater than 100%. An additional field of "Percent Of Spawner Scale" appears underneath if you choose this option and defaults to 100%.
    •  
    • Custom Scale: This allows you to specify a custom scale for your spawns.
  34.  
  35. Retrigger Limit Mode: This allows you to prevent the prefab from spawning multiple of the same Wave (by that event type) by specifying the minimum reactivation time in seconds or frames since the previous activation. In other words, if you don’t want a Mouse Click to spawn a Wave more than twice a second, you can set Retrigger Limit Mode to "Time Based" and Min Seconds Between to 0.5. This settings defaults to "none", meaning no limitation is made.
  36.  
  37. Wave Spawn Bonus & Events: Instead of Repeat Wave Bonus (as Syncro Spawners have), Triggered Spawners have a Wave Spawn Bonus, which works a little differently. This is a set of World Variable modifiers as well, but it triggers even on the first spawn of a triggered Wave.
       
    • Use on First Spawn: Defaults to checked. Uncheck if you wish to use Wave Spawn Bonus only for repeats (below).
    •  
    • There is also a checkbox in the Repeat Wave section if you want to use the Wave Spawn Bonus for each repeat.
  38.  
  39. Wave Elimination Bonus & Events: Appears only when you have set Wave Completed When to "Items Eliminated". Works exactly like Wave Spawn Bonus & Events, just happens when the Wave is eliminated.
  40.  
  41. Wave Elimination Bonus Prefab: Appears only when you have set Wave Completed When to "Items Eliminated". Checking this box will allow you to spawn a bonus prefab after the wave has been eliminated.
       
    • Bonus Prefab: Specify the prefab to spawn.
    •  
    • Spawn % chance: Specify the percent chance to spawn the bonus prefab. i.e. 30% means that 30% of the time it will spawn bonus prefab(s), and the other 70% it will not.
    •  
    • Spawn Quantity: Specify the quantity of the bonus prefab to spawn if the % chance randomly succeeds.
  42.  
  43. Spawn Limit Controls: Checking this box will allow you to limit items spawned by various criteria. Note that these controls can make it take longer than "Time To Spawn All" to spawn the whole wave.
       
    • Use Min Distance: On by default. Turn it off to disable Min Distance Checking. The following options are for Min Distance:
         
      • Min. Distance: Before spawning each item, the Spawner will make sure all items spawned so far are at least this distance from the Spawner. If not, it will delay spawning another item until they are.
      •  
      • Random Distance: If this is non-zero, a random number between "negative this" and "positive this" will be added to the Min. Distance prior to performing the Min Distance Check. So if you chose Min Distance of 8, and Random Distance of 3 then the possible range it will use for Min Distance would be 5-11 (8-3 = 5 and 8+3 = 11).
    •  
    • Use Spawn Cap: Off by default. Turn it on to delay spawning any items more than the max you specify.
         
      • Spawn Cap: This is the maximum number you wanted spawned at any time. Further spawning should be delayed until an item is despawned.
  44.  
  45. Repeat Wave: Turning this on will force your Wave to repeat automatically when your Wave is completed. If Repeat Wave is on, that section looks like this:
     

     

    The following controls appear here:

       
    • Repeat Mode: There are 4 choices:
         
      • Number Of Repetitions: You choose the number of repetitions with the next field.
           
        • Repetitions: How mamy times to repeat the Wave.
      •  
      • Endless: This loops the Wave forever.
      •  
      • Until World Variable Above: This will repeat the Wave until 1 or more World Variables equal or exceed values you specify below with the "Variable Limit" dropdown and controls.
           
        • Add Variable Limit: Use this to add Limits for the above Repeat Mode. For example, add "score" and the value 1000 to make the Wave repeat until you reach 1000 score.
      •  
      • Until World Variable Below: This will repeat the Wave until 1 or more World Variables equal or are less than values you specify below with the "Variable Limit" dropdown and controls.
           
        • Add Variable Limit: Use this to add Limits for the above Repeat Mode. For example, add "Health" and the value 100 make the Wave repeat until you drop down to 100 Health.
    •  
    • Repeat Pause Min/Max: The amount of time to wait after Wave completion before repeating your Wave again. It will be a random number between these two values.
    •  
    • Spawn Increase: This allows you to make the repeated Wave have more items spawned than the original. Or vice versa.
    •  
    • Spawn Min Limit: This allows you to set a ceiling that the Spawn Increase plus current Wave size will never go below. Think of it as "min Wave size".
    •  
    • Spawn Max Limit: This allows you to set a ceiling that the Spawn Increase plus current Wave size will never exceed. Think of it as "max Wave size".
    •  
    • Reset On Spawn Limit Reached: If you check this, the "increase" fields will reset back to zero (original Wave setting) whenever the limit (min or max) is reached. This allows you to do things like have a repeating Wave that spawns 5, 6, 7, 5, 6, 7, etc (resetting back to 5 if 7 is the limit).
    •  
    • Time Increase: This allows you to make the repeated Wave "Time To Spawn All" longer than the original Wave. Or vice versa.
    •  
    • Time Min Limit: This allows you to set a ceiling for the "Min Wave Spawn Time" so that the Time Increase being added every repeat will never make it shorter than this value.
    •  
    • Time Max Limit: This allows you to set a ceiling for the "Max Wave Spawn Time" so that the Time Increase being added every repeat will never make it longer than this value.
    •  
    • Reset On Time Limit Reached: If you check this, the "increase" fields will reset back to zero (original Wave setting) whenever the time limit (min or max) is reached. This allows you to do things like have a repeating Wave that spawns for 5, 6, 7, 5, 6, 7 seconds (resetting back to 5 if 7 is the limit).
    •  
    • Use Wave Spawn Bonus: This is only visible if you have enabled Wave Spawn Bonus for this Wave. This checkbox controls whether all repeats of the Wave also modify the same World Variables.
    •  
    • Repeat Custom Events: If you check this box, you can assign a set of Custom Events that will be fired every time the Wave is repeated.
     
  46. Randomization: Turning this on will allow you control over randomizing the position and rotation of your spawned prefabs:
       
    • Random Rotation X/Y/Z: You can specify you want random rotation on the X, Y, and Z axes, or any combination thereof. Any axes you do not check will use the original prefab’s rotation. For each axis you enable random rotation for, a pair of sliders will appear underneath called "Rand. X Rot. Min" and "Rand. X Rot. Max" for the X axis, etc. These will limit the minimum and maximum angle for your spawned items. By default the entire 0-360 degree range is used. You can narrow this to enable smaller ranges of random angles as seen in a popular fruit slicing mobile game.
    •  
    • Random Distance X/Y/Z: You can specify that you want the prefab’s spawn location to be a within a certain distance of the Spawner instead of exactly where the Spawner is. If you set Random Distance X to 10 for instance, it will add a random number between -10 and 10 to the spawn position. The same goes for Y and Z.
  47.  
  48. Incremental Settings: Turning this on will allow you to have each successive item in a Wave spawn with a changing starting position or rotation. This allows you to spawn a row of enemies (a la Space Invaders), or a Wave of enemies rotated to cover 180 degrees of fire. The settings are as follows:
       
    • Distance X/Y/Z: You can specify that each successive spawned item has an extra X * item number to its spawn location. In other words, if you put 10 for X:
         
      • Item 1 spawns from the Spawner location.
      •  
      • Item 2 spawns from the Spawner location + 10x.
      •  
      • Item 2 spawns from the Spawner location + 20x, etc.
    •  
    • Rotation X/Y/Z: You can specify that each successive spawned item gets rotated an extra X degrees from the prefab rotation. So if you put 40 for X:
         
      • Item 1 spawns with the prefab’s rotation.
      •  
      • Item 2 spawns with the prefab’s rotation + 40 degrees X (Euler).
      •  
      • Item 3 spawns with the prefab’s rotation + 80 degrees X (Euler), etc.
    •  
    • Keep Center: Check this if you would like the incremental rotation settings be equally split between left and right. It enables effects like Contra's infamous spread shot. The Triggered Spawner example scene has an enemy using this for it's attack.
  49.  
  50. Post-Spawn Nudge Settings: Turning this on will allow you to alter the spawned prefab’s position immediately after it has been spawned and rotation has been applied, whether that rotation came from Incremental or Random Settings. This can make it possible to spawn a ring of enemies where you set the radius of the ring here, and other cool patterns.
       
    • Nudge Forward: This controls the distance to nudge the prefab forward after spawning.
    •  
    • Nudge Right: This controls the distance to nudge the prefab to the right after spawning.
    •  
    • Nudge Down: This controls the distance to nudge the prefab down after spawning.