FPS ENGINE DOCUMENTATION
  • Welcome to FPS Engine!
  • BEFORE WE START
    • Early Considerations
    • List of Tutorials
    • List of Add-Ons & Compatible Packages
  • GETTING STARTED
    • 01. Basic set-up
    • 02. Roadmap
  • CONTENT
    • 03. Content
      • 03.1 CAMERA
        • MoveCamera
        • CameraFOVManager
      • 03.2 MOVEMENT
        • PlayerMovement
      • 03.3 PLAYER
        • PlayerStats
        • PlayerMultipliers
        • PLAYER STATES
          • PlayerStates
          • PlayerBaseState
          • PlayerStateFactory
        • WEAPON STATES
          • WeaponStates
          • WeaponBaseState
          • WeaponStateFactory
        • Player Debugging
      • 03.4 WEAPONS
        • Weapon_SO
        • WeaponIdentification
        • WeaponController
        • Bullet
        • ATTACHMENTS
          • Attachment.cs
            • Barrel.cs
            • Flashlight.cs
            • Magazine.cs
            • Scope.cs
            • Stock.cs
            • Laser.cs
            • Grip.cs
          • AttachmentIdentifier_SO.cs
      • 03.5 PICK UP SYSTEM
        • InteractManager
        • Interactable
        • Item_SO
        • Identifiable
        • Pickeable
          • WeaponPickeable
          • BulletsPickeable
          • AttachmentPickeable
      • 03.6 ENEMIES
        • IDamageable
        • EnemyHealth
        • TrainingTarget
        • CIrcularTargetEnemy
        • Turret
        • TurretProjectile
      • 03.7 EFFECTS
        • CameraEffects
        • CamShake
        • CrouchTilt
        • JumpMotion
        • ProceduralShot
        • ProceduralShot_SO
        • WeaponEffects
        • WeaponSway
      • 03.8 UI
        • CowsinsButton
        • Crosshair
        • CrosshairShape
        • Hitmarker
        • UIController
        • UIEvents
        • RebindUI
      • 03.8 EXTRA
        • Checkpoint
        • Coin
        • Compass
        • CompassElement
        • Destructible
        • Crate
        • ExplosiveBarrel
        • PowerUp
        • DamageMultiplier
        • HealMultiplierPowerUp
        • Healthpack
        • DoorInteractable
        • Experience
        • GetGameInformation
        • HurtTrigger
        • JumpPad
        • Lootbox
        • PauseMenu
        • PointCapture
        • Trigger
        • DraggableButtonInSceneView
        • UTILITIES
          • DestroyMe
          • IgnoreCollision
          • LookAt
          • CowsinsUtilities
      • 03.09 MANAGERS
        • CoinManager
        • ExperienceManager
        • GameSettingsManager
        • InputManager
        • SoundManager
        • PoolManager
  • HOW TO USE
    • Getting Started: First Steps
    • Importing FPS Engine into URP / HDRP
    • Add a Player Controller
    • Adding New Weapons
    • Saving & Loading Presets
    • Changing Keybindings
    • Creating New Pickeables
    • Controllable & Not Controllable Player
    • Adding New Surfaces ( Grounds )
    • Working with Attachments
    • Modify Weapon and Camera Effects
    • Adding Custom Key Rebinds
    • Add breakable (Destructible) objects
    • Custom Shot Weapons
    • Adding Enemies
  • FAQ
    • FAQ
  • SUPPORT
    • Support
Powered by GitBook
On this page
Export as PDF
  1. HOW TO USE

Working with Attachments

PreviousAdding New Surfaces ( Grounds )NextModify Weapon and Camera Effects

Last updated 10 months ago

Refer to this tutorial for instructions on working with attachments. This section of the documentation will cover the same steps in detail.


This is how you can add attachments using FPS Engine. First you will need a fully set up weapon, so if you do not have that, make sure to do that step first. Refer to

For this guide we will make a new “Barrel” using a simple built-in cylinder.

Open your desired weapon prefab and drag and drop your attachment model. For the sake of this guide, as said earlier, we will add a cylinder, and place it where the attachment is supposed to be placed, for ours, in the tip of the gun, as seen in the pic:

It is highly recommended to place attachments as a child of the weapon, so it moves with it. Now, select the attachment and add the appropriate Attachment script to it, you can choose from the following:

Notice that, inside your component, it asks you to assign an attachment identifier.

Each attachment requires an attachment identifier ScriptableObject, functioning similarly to Weapon_SO. If multiple weapons use the same ScriptableObject, they can share attachments. For instance, if two weapons share the same barrel type, both barrels are recognized as the same attachment because they share the attachment identifier ScriptableObject, even if they are part of different game objects within different prefabs.

To create a new unique AttachmentIdentifier_SO, right-click on the Project folder, then select Create → Cowsins → New Attachment Identifier.

You can set different parameters for your attachment, like the name, the icon of the pick-up graphics.

THESE PICK-UP GRAPHICS ARE ONLY DISPLAYED ON PICK UP OBJECTS, THIS IS NOT THE ACTUAL ATTACHMENT MODEL.

Once that is completed, return to your attachment and choose the attachment identifier we just created. You can also adjust attachment settings as desired. Keep in mind that these settings are cumulative, as multiple attachments may be applied to a weapon.

Next, navigate to the root of your weapon prefab and assign the attachment object (not the ScriptableObject) within the corresponding CompatibleAttachments section. In this case, place it under Barrels since it is a barrel attachment. Afterwards, ensure to deactivate your attachment to prevent it from being displayed on-screen.

If you want this attachment to be a default option, you can also add the attachment object to the appropriate DefaultAttachment slot. Since it's a barrel attachment, place it under DefaultBarrel to avoid potential unexpected issues.

Since we are making a Barrel, we will add Barrel.cs, note that all these scripts inherit from

Check for more information.

Barrel.cs
Scope.cs
Stock.cs
Magazine.cs
Grip.cs
Flashlight.cs
Laser.cs
Attachment.cs.
AttachmentIdentifier_SO
Adding New Weapons