Laser Barrel

The LaserBarrel is a unique implementation of the base barrel system that fires a continuous laser beam using Unity’s LineRenderer. It’s ideal for sci-fi weapons where the bullets are beam energy.

Add Component: Glowing Rifts > Modular Weapon > Laser Barrel

✅ Ideal For

  • Laser rifles
  • Beam weapons
  • Sci-fi turrets
  • Mining or cutting tools

⚙️ How it works

The laser barrel simulates a curved beam rendered in real-time using a LineRenderer. This beam is dynamically shaped with the help of a CubicSpline algorithm that gives it a natural arc.

  • The laser snaps to the closest target based on a configurable Snap Radius
  • Impacts are processed once a valid object is hit on the specified Affected Layer
  • For a wind-up before the beam fires, add a Spool to the same GameObject
  • The laser is continuous but it consumes hypothetical bullets from the weapon’s magazine, at the barrel’s fire rate.

Note

Each bullet consumed will inflect the damage point on the target.

📐 Additional Settings

Aside from the base barrel logic, the laser barrel includes these unique options highlighted in the red box in the image below

FieldDescription
Laser Settings > LineReference to the LineRenderer component that renders the laser beam
ResolutionNumber of spline points used to generate the beam curve
RadiusWidth of the beam
Snap RadiusRadius within which the beam will snap to valid targets
Max LengthMaximum distance the laser can reach if nothing is hit
Affected LayerDetermines what layers the laser can affect (damage or snap to)
Laser Events > On Impact (Vector3)Called every frame the beam is on, with the impact point

Note

The beam settings are grouped under Laser Settings, and the damage comes from the barrel’s Config stats.


🌀 Curved Laser with Cubic Spline

The LaserBarrel uses a Cubic Spline algorithm to simulate realistic beam curvature. This curve is recalculated each frame to give the laser a fluid, reactive feel. The spline adapts to target poisition if they are still within radius

Tip

Adjusting Resolution and gives you fine control over laser quality vs performance.