🔫Weapon setup
In this section you will find out how add weapons.
Last updated
In this section you will find out how add weapons.
Last updated
First, we need to add a weapon model and create a prefab. We will use the AK model from the demo:
Tip: make sure the weapon is pointing Z positive forward. It's crucial for the weapon positioning in the future!
Add a Weapon.cs component to your weapon prefab. Click on the FPSAnimWeapon Interface button to expand the contents, and then click the Setup Weapon button:
Once you've clicked the button, AimPoint and PivotPoint game objects will be added to your weapon.
Pivot Point defines the physical pivot of the weapon, and it's only useful for procedural animatipns. You can leave it at a default position or adjust it to your liking.
Aim Point defines the defalt aiming socket of the weapon.
Additionally, you can create another GameObject - Left Hand Target, which will be used by Left Hand IK Layer.
Make sure to specify default Fire Mode, Fire Rate and Burst Amount (if supported by the weapon).
Now we need to adjust other weapon properties, which are not part of the animation framework:
Warning: when selecting Reload/Grenade/Fire clips make sure they have the same animation type as your character! Generic animations WILL NOT work with a humanoid character and vice versa.
Overlay Type defines what type of weapon we have. The demo project only supports Default, Pistol and a Rifle. It's only used in the Animator Controller to select the sprinting animation.
Scopes list contains all the Aim Points, so make sure to add all the aiming sockets here.
Recoil Patter defines settings for the recoil system.
Camera Shake defines firing shake effect or camera recoil.
Smoothing defines how smooth the recoil should be.
Acceleration defines the recoil speed change with every shot.
Step defines the vertical recoil.
Horizontal Variation defines the horizontal recoil, which is random in range [X:Y].
Aim Ratio scales the final recoil values when aiming.
Camera Weight controls how the camera is affected by the recoil. If set to 0 - camera will always follow the recoil, if set to 1 - the camera won't be affected by the recoil and will always compensate the recoil.
Camera Restore Speed defines how fast the camera will lerp back to the base rotation. Only applicable if the Camera Weight is more than 0.
Camera Shake is a Scriptable Object, which contains the settings for the curve camera shake. It's used for firing in the demo project, but you can use it for other fire-and-forget type of actions (hard landing, for example).
Shake Curve - vector curve for each rotation axis.
Pitch/Yaw/Roll are the target Vector4 values for each axis. The final value is calculated in this way:
Smooth Speed defines the interpolation smoothing speed. No smoothing applied if zero.
Play Rate defines the playback speed.
Now it's time to add our weapon prefab to the character. Drag it the scene and parent to the character WeaponBone object:
Now we need to add the weapon to the list in the FPSController:
The last thing left to do is Weapon Anim Asset.
You can find more about properties of this asset in Weapon Anim Asset.
For now let's create a new asset (Right Click -> Create -> FPS Animator -> WeaponAnimAsset).
Let's start with General settings:
As a Recoil Data you can create a new or use an existing one from the demo project. You can find more about the Recoil Data asset in Recoil Layer.
Let's create a new Overlay Pose for our weapon. Right Click -> Create -> FPS Animator -> Anim Sequence:
Assign the animation Clip and the Blend In Time. Make sure you use the proper animation type! Grab the reference to the Sway Overlay Pose and assign it in the WeaponAnimAsset.
Now open up your weapon prefab and assign the WeaponAnimAsset:
The final step is to adjust default weapon position.
First, play a static animation of your choice (via FPSAnimator/Layers/Play function) and position the gun manually:
Once you are done, and the pose looks fine - go to the weapon prefab and hit the Save Weapon Position button:
This will write the current weapon position into the WeaponAnimAsset automatically.
Tip: make sure to set the weapon position to zero once you are done!
At this point the setup is complete, and you can test it in game.
If you have any questions about the setting up process, please, join our support Discord server and create a ticket in public support!
Select the Aim Offset Table we created back in .