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:
- A ray is cast from the spawn point in its forward direction.
- 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
Field | Description |
---|---|
Range | Max distance of raycast or projectile |
Layers | Which layers can be hit |
Damage Points | How much damage each shot deals |
Impacts | Prefabs spawned when a hit is registered |
On Hit Event | Allows advanced logic or effects when a hit occurs |