There are three different kinds of despawners included with Core GameKit. They each are for different scenarios.
Triggered Despawner: (Generally not needed if you use Killable on your Game Objects). This is an extension of the Triggered Spawner, but for despawning purposes. This can be used to make prefabs automatically despawn when they go off camera, hit objects from certain Layers and more. It is attachable to a prefab from the Component menu under
Dark Tonic -> Core GameKit -> Despawners -> Triggered Despawner. It has the following events you can trigger despawn from:
MonoBehaviour Events: Usable with no plugin requirement.
Note: For Collision and Trigger Events, there are the same optional Layer and Tag Filters as we used in Triggered Spawners.
- Trigger Enter
- Trigger Exit
- Collision2D Event
- Trigger Enter 2D
- Trigger Exit 2D
- MonoBehaviour Events: Usable with no plugin requirement.
Particle Despawner: This is a script that automatically despawns a prefab with a Particle System (Shuriken) as soon as all the particles have disappeared. It is attachable to a prefab with a Particle System from the Component menu under
Dark Tonic -> Core GameKit -> Despawners -> Particle Despawner.
- Wait On Child Object Particles: Defaults to off. Turn it on to wait until all particles from child Game Object's are finished as well.
Note: If you are especially concerned with performance (mobile games are), you can put a Timed Despawner Component (described next) on a Particle System. It is much lighter on performance. You just need to figure out how long the particle should be visible if you go that route.
Timed Despawner: This is a script that will despawn a prefab after a preset amount of time that you set. It is attachable to a prefab from the Component menu under
Dark Tonic -> Core GameKit -> Despawners -> Timed Despawner. It has a couple settings:
- Start Timer On Awake: If checked (the default), the timer will start as soon as the prefab is spawned or awake. If not, you will need to call the "StartTimer" method through code when you wish to start the timer.
- Despawn Timer (sec): This is how long the countdown timer is before despawning.