Initialization

To begin setting up a weapon using the Modular Weapon System, you’ll first need to create the weapon prefab in your Unity scene.

🧱 Create the Weapon Root

  1. In the Hierarchy, right-click and create an empty GameObject.
  2. Rename it to match the weapon you’re building (e.g., Pistol).
ℹ️
This object will hold the Weapon script and serve as the entry point for all other modules.

🎯 Add a Recoil Handler

If you want your weapon to have recoil behavior:

  1. Right-click your weapon root and create a child GameObject.
  2. Name it Recoil.
  3. Set its Position and Rotation to 0,0,0 to center it properly.
ℹ️
This object will act as a pivot point for applying recoil movement.

🔗 Attach the Weapon Model

  1. Drag and drop your weapon model (e.g., a 3D pistol) as a child of the Recoil GameObject.
⚠️
If you don’t want to use recoil, just add it as child of the root
  1. This structure allows the recoil object to apply movement to the visual mesh without affecting the weapon’s logic or transform root.

Your hierarchy should now look like this:

“Hierarchy”

➕ Add the Weapon Component

  1. Select the root of the gameobject “Root gameobject”
  2. Add the Weapon component as following “Weapon Component”

💾 Save Prefab

  1. Drag and drop the root gameobject into your project to create a prefab

⏭️ Next Step

Let’s add next a barrel to our pistol to enable it to shoot bullets