⚙️Weapon System
In this page we will cover how the weapons works in the project.
Weapon Components
From the previos chapter we know that Weapon Manager and Viewmodel Controller are used to manage weapons. First, let's clarify the differences between these components:
Weapon Manager: spawns and swaps weapons; works like a simple inventory system.
Viewmodel Controller: tells what weapons and character mesh to use; controls the first-person view.
Each component does not work out of the box. Instead, they provide basic functions that are supposed to be called in a player blueprint (BP_Viewmodel example).
Weapon Manager
This component has to be initialized when the game starts:

Next, it is used to change weapons:

This method will invoke a weapon change with animation. However, there is a function that allows instant weapon change:

If Forward it true, the next weapon will be equipped, if false - the previous one.
Finally, Weapon Manager is used to manually update Weapon Settings when switching between UE4/UE5 meshes:

You can find out more about the internal logic of the Weapon Manager component by opening its Blueprint (Blueprints → Character → WeaponManager).
Viewmodel Controller
Before working with the component, it is vital to assign the Character Settings asset:

Viewmodel Controller serves as an interface between the gameplay lofic and animation blueprints. That is why it is essential to update its public properties manually:

The Gait parameter represents the normalized character movement state:
[0;1] range defines a transition between idle and walking.
[1;2] range defines a transition between walking and sprinting.
[2;3] range defines a transition between sprinting and tactical sprinting.
Next, we need to update the firing trigger state - it will control the index finger rotation:

To active procedural aiming, make sure to update the aiming flag:

Finally, we can use Viewmodel Controller to play custom IK Motions - simple transition animations which can make flat transitions feel more dynamic.
Tip: IK Motion is used when aiming down sights.

We will cover the IK Motion asset later in the documentation. Now let's figure out how weapons work.
Last updated