Raycast Barrel

The RaycastBarrel is the default and most performant implementation. It uses Unity’s Physics.Raycast to simulate instantaneous hits—ideal for modern firearms or sci-fi weapons.

✅ Ideal For

  • Pistols
  • Rifles
  • Laser weapons

⚙️ How it works

Each time the barrel fires:

  1. A ray is cast from the spawn point in its forward direction.
  2. If a hit is detected, an event on hit is triggered that you can use:
    • Spawns visual effects (e.g., muzzle flash, bullet holes)
    • Applies damage via DamageData

Note

RaycastBarrel is best for precise, fast-paced shooting systems where projectile physics are not needed.

📐 Additional Settings

Aside from the base barrel logic, the raycast barrel has additional settings highlighted in the red box in the image below

FieldDescription
RangeMax distance of raycast or projectile
LayersWhich layers can be hit
Damage PointsHow much damage each shot deals
ImpactsPrefabs spawned when a hit is registered
On Hit EventAllows advanced logic or effects when a hit occurs