Projectile Barrel
The ProjectileBarrel spawns physical projectiles like grenades, rockets, or arrows. It instantiates a ProjectileAmmo prefab, sets its position and rotation, and launches it.
Summary
This component:
- Inherits from 
Barrel - Spawns a projectile prefab each time it fires
 - Sends damage and ownership data to the projectile
 - Optionally exposes projectile instantiation events
 
Fields
| Field | Type | Description | 
|---|---|---|
projectilePrefab | ProjectileAmmo | Prefab to instantiate and fire. | 
damagePoints | int | Damage value passed to the projectile. | 
pooled | bool | Optional field for future pooling logic (not active). | 
prewarmCount | int | Number of projectiles to pre-instantiate if pooling. | 
OnProjectileSpawned | UnityEvent<ProjectileAmmo> | Event fired after the projectile is instantiated. | 
Public Methods
| Method | Description | 
|---|---|
override void Shoot() | Calls base, instantiates a projectile, and launches it. | 
Private Methods
| Method | Description | 
|---|---|
IEnumerator SpawnBullet() | Instantiates and sets up the projectile after a frame delay. | 
Behavior
- Each time the barrel fires, 
Shoot()spawns a newProjectileAmmoinstance. - The projectile inherits position and rotation from 
spawnPoint. - The 
Shoot()method on the projectile receives:damagePointsfrom this barrelGameObjectreference of the weapon as the instigator
 
Tip
Use OnProjectileSpawned to trigger sound effects, animations, or custom tracking logic.
Note
Although pooling fields are defined, pooling is not yet implemented in this version.
Use Case Examples
- Grenade launchers
 - Rocket launchers
 - Shotguns using physics projectiles
 - Throwable weapons