Launcher

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).

  • Play Mode: the projectile is spawned and launched Only once or continuously (Loop).

  • Cooldown: the time (in seconds) between two spawn events.

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, so you can set the damage.

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.

Last updated