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).
This component has to be initialized when the game starts:
Call Initialize Weapon first.
Next, it is used to change weapons:
Changing Weapons.
This method will invoke a weapon change with animation. However, there is a function that allows instant weapon change:
Immediately equips next or previous weapon.
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:
Swapping meshes.
You can find out more about the internal logic of the Weapon Manager component by opening its Blueprint (Blueprints → Character → WeaponManager).
Before working with the component, it is vital to assign the Character Settings asset:
Assign Character Settings.
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:
Update Gait.
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:
Animates the right index finger when firing.
To active procedural aiming, make sure to update the aiming flag:
Update aiming.
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.
Select an IK Motion.
We will cover the IK Motion asset later in the documentation. Now let’s figure out how weapons work.