Adding New Weapons
Last updated
Last updated
Refer to this tutorial for instructions on adding new weapons. This section of the documentation will cover the same steps in detail.
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!
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.
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
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.
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.
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.
Open the animation controller for the weapon you desire to add a new Animation State.
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."
Make a new state and add a motion ( Animation Clip )
Add the required animation transitions.
Look for the suitable method where you want to introduce the state by code. Then write this:
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 .