# Launcher

![](https://4289778471-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVKw8MgRKSYbFzCqlnm%2F-MW4gJgMgrILKkXZ-Y6-%2F-MW4rdHq_TmAHFs_tddC%2Flauncher-illustration.PNG?alt=media\&token=6c18f9da-b871-4a33-919f-bd9916396dfe)

This component shoots a projectile using object pooling. In short, it only instantiates a number of projectiles then reuses the already instantiated. This is good for performance. ([more information here](https://learn.unity.com/tutorial/object-pooling)).

* **Play Mode:** the projectile is spawned and launched Only once or continuously (Loop).
* **Cooldown:** the time (in seconds) between two spawn events.

![](https://4289778471-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVKw8MgRKSYbFzCqlnm%2F-MW4bB32nMlUbPym5-Nw%2F-MW4d_7CCHIhMK6gRISg%2Flauncher.PNG?alt=media\&token=63a678c8-6391-43c1-aada-e70dc3c2ef56)

**Launcher Settings**

* **Force:** the force that is applied to the projectile
* **Max Distance:** projectile deactivates and returns to the pool after this distance even if it didn’t collide with anything.
* **Ammunition:** you can limit how many times the launcher can shoot. 0 means unlimited ammo.
* **Stick on Collision:** the projectile will stick to and move with the object it collides with. It disappears when the object pooler reuses it. Useful for arrows or darts.

**Projectile Settings**

* **Projectile:** The script can handle multiple **projectile prefabs**.  By default, it shoots the listed projectiles one by one, based on their order. Enable the Randomize option for random selection.
* **Pool Size:** the script will instantiate only this amount of projectile from each prefab.

### Trap Projectile

This component moves the projectile. It’s inherited from a [Damage Source](https://runemarkstudio.com/deadly-dungeon-traps/documentation/damage-system/), so you can set the damage.

![](https://4289778471-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVKw8MgRKSYbFzCqlnm%2F-MW4bB32nMlUbPym5-Nw%2F-MW4eTVR43KfB723zZRr%2Fprojectile.PNG?alt=media\&token=692d4cdf-a076-4ef2-a4a6-ac8f2076a89d)

To create a **projectile prefab** to be used in the launcher, simply attach this script to a game object and save as a prefab in your Project folder.

![](https://4289778471-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVKw8MgRKSYbFzCqlnm%2F-MW4bB32nMlUbPym5-Nw%2F-MW4fD6W5aL1IAE25_Wp%2Fprojectile-prefab.PNG?alt=media\&token=789d83e5-a71e-4432-b689-22a4d2658f01)
