Shotgun Barrel

The ShotgunBarrel is a specialized type of RaycastBarrel designed to simulate the behavior of a shotgun. It inherits all the logic from the base barrel, but fires multiple projectiles in a spread pattern.

Add Component: Glowing Rifts > Modular Weapon > Shotgun Barrel

✅ Ideal For

  • Shotguns
  • Scatterguns
  • Energy blasters

⚙️ How it works

Each time the barrel fires:

  1. Each bullet (shell) splits into Pellets Per Bullet pellets, so one shot casts Bullets Fired x Pellets Per Bullet rays in random directions within a cone defined by the Spread value.
  2. Each ray:
    • Applies damage
    • Triggers On Hit events
    • Can spawn independent visual or physical impacts

Note

The ShotgunBarrel sacrifices pinpoint accuracy for wide coverage, making it perfect for close-range combat.

📐 Additional Settings

Aside from the raycast barrel logic, the shotgun barrel has extra settings highlighted in the red box in the image below

FieldDescription
RangeMax distance of raycast or projectile
LayersWhich layers can be hit
ImpactsPrefabs spawned when a hit is registered
Hit Events > On HitInvoked for each pellet that hits, with the impact point and normal
SpreadThe angle in degrees to randomly offset each pellet. Higher values result in a wider spread.
Pellets Per BulletPellets each bullet splits into. Each pellet deals the full per-bullet damage from the barrel’s Config
Pellet TraceParticle system that draws the pellet traces. One trace is emitted per pellet that hits

Tip

Keep Bullets Fired at 1 for a classic shotgun. Raise it for a double-barrel that fires two shells at once.