Adding Barrels

Barrels are essential components. They define how and where the weapon fires, and control the shooting logic, bullet type, and associated effects such as sounds and visual effects.

🔘 Choose the Barrel Type

For this example, we’ll use a Raycast Barrel, which simulates hitscan shooting used in the pistol

🎯 RaycastBarrel prefab is included in the package under modularweaponsystem/content/barrels

“Project Structure”

📦 Drag and Drop the Barrel

  • Drag and drop the RaycastBarrel under the PistolModel in the prefab.

“Project Structure”

ℹ️
the raycast barrel prefab can contain sounds and VFX objects

📍 Align the Barrel

  • Position the barrel so that its forward direction (blue Z axis) matches the shooting direction.

“Project Structure”

ℹ️
It should sit at the the barrel should be placed on the tip of the weapon’s barrel.

✨ Customize Effects (Optional)

Once placed, the barrel will:

  • Automatically handle shooting logic when the weapon fires.
  • Play assigned sound effects, muzzle flashes, and animations.
  • You can assign and customize these via the inspector.

“Project Structure”

Each weapon can have multiple barrels if needed. Just ensure each one is positioned and configured properly.

⏭️ Next Step

Now that we have added the barrel to our prefab, it execpects a magazine object to have clip and reload data hooked to it. That’s where the magazine object comes in next.