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
  • Requirements
  • Procedure
  • Adding Animations
  • Custom Animation States
  • Best Practices
Export as PDF
  1. HOW TO USE

Adding New Weapons

PreviousAdd a Player ControllerNextSaving & Loading Presets

Last updated 10 months ago

Refer to this tutorial for instructions on adding new weapons. This section of the documentation will cover the same steps in detail.


Requirements

In order to add a new Weapon, you will need:

  • Custom arm Rig and Weapon models if desired.

  • Custom VFX if desired.

  • Custom SFX if desired.

Note that you can use the assets provided by FPS Engine if you want!

Procedure

You can create a unique Weapon_SO for each weapon by right-clicking in your Project folder, going to Create → COWSINS → New Weapon.

When you create a New Weapon_SO, all the variables will be resetted, you can apply a Preset or duplicate an existing Weapon_SO instead.

To apply a preset simply select it on "currentPreset" and apply.

Once we have the Weapon_SO created, we need a Weapon Prefab. We will search the CowsinsBlankWeaponTemplate which is located under the following path.

We want to duplicate this object ( Ctrl+D ) and give it a name, then open it.

Here, we will import our model under “Meshes”. Note that the cube is approximately the size and location of the weapon we want to add. When you are happy with the location of the model, delete the cube.

In FPS Engine, the Weapon Prefab should contain both the Arms and Weapon

Now create a new empty object as a child of the imported model and call it FirePoint. Note that you can create as many fire points as you want, so you can make two handed weapons etc. You want to locate the fire point at the tip of the barrel.

We will need to locate the AimPoint at the Iron Sights / Scope

Now go to the root of the prefab and attach your fire points, the Aim Point and the Weapon_SO we created before.

Now, go to your scriptable object and attach this prefab into weaponObject, under the Basic tab.

Just like this, our Weapon is ready. If you want to add Animations to the Weapon, refer to the next section

Adding Animations

There is an animator attached to the root of the Weapon Prefab. You should ensure you move this Animator component to exactly the root of your Animations. If you imported an animated Rig from Blender, the imported object is likely to be the root.

Animator Component Miss Placement will result in the Animations not working.

Please, ensure you locate the Animator Component Properly.

If you want to animate inside Unity, you can leave the component at the root of the Prefab, or re-locate it if you wish.

As you can see there is no Animation Controller Attached to this Animator component, so we need to create it. There is an Animation Controller template stored in the following path: Assets/Cowsins/Animations/AnimationControllerTemplate.

You can duplicate this and attach it to your “Controller” on the Animator component.

You can open this animation controller and take a look. This will pop up:

As you may notice, all these parameters and structure are already set-up.

All you have to do is to create an animation for each state (Idle, Unholster, Shoot, Reload) and then attach them to each animation State( If you already have the animations, directly attach them to the corresponding states ).

For example: Let´s say we have just made an idle animation. Click on the Idle Animation State.

Attach your animation in Motion. Repeat the process with the remaining animation States.

he length of animations like Reload depends on the statistics you set for your weapon (such as Reload time). For shooting, the length doesn't matter if you use the blank template, as the animation will restart after each shot. For idle, walk, run, and inspect animations, these should be the only ones marked as "loop."

Custom Animation States

You can create custom animation states if needed, but note that these are not provided by the asset, so you will have to set them up yourself. Below, you will find a guide on how to do this effectively using FPS Engine.

  1. Open the animation controller for the weapon you desire to add a new Animation State.

  2. Go to the Parameters tab for this Animation Controller and click on the "+" button. Add a Trigger, name the new parameter, and remember its name. For example, you can name it "myCoolNewBoolean."

  3. Make a new state and add a motion ( Animation Clip )

  4. Add the required animation transitions.

  5. Look for the suitable method where you want to introduce the state by code. Then write this:

CowsinsUtilities.PlayAnim("myCoolNewBoolean", 
    inventory[currentWeapon].GetComponentInChildren<Animator>());

Best Practices

It is highly recommended to use the provided template for creating weapons. Following the same structure as the example weapons included with the asset is advisable as well.

First, we must create a new . You can store them anywhere , but it´s good practice to keep them all in the same folder.

Now, you can modify all the parameters as you need to create your desired Weapon! If you need further explanation on what each parameter does, please refer to .

If you can't find the appropriate function, feel free to ask for .

Weapon_SO
Weapon_SO
support