The FPS Animation Pack offsers an example BP_Viewmodel character blueprint, which is a playable character used in the demos. This character blueprint has a modular structure:
BP_Viewmodel character.
While it contains basic components and properties like any other character, BP_Viewmodel has distictive features:
Camera - parented to the FP_Camera socket, which is parented to the head bone.
WeaponMesh - SkeletalMeshComponent used for currently equipped weapon.
CameraAnimator - used to play camera animations and recoil shakes.
ViewmodelController - used as an interface between the gameplay and animation blueprints.
Recoil Animation - used to play procedural firing animations.
Weapon Manager - used to handle weapon creation and swapping logic.
We will cover each component in detail in the next chapters. The BP_Viewmodel is responsible for general gameplay logic, like movement and player rotation. All actions that depend on a weapon are handled via Event Dispatchers:
All events used by the character blueprint.
Tip: you will find all the main logic implemented in the Event Graph.
For example, when a user wants to reload a weapon, the BP_Viewmodel is only going to receive the input, and then invoke the bound event:
Reload action example.
Now let’s focus on the logic implemented by the BP_Viewmodel.
Here we use the Weapon Manager component to initialize all weapons based on the character settings provided by the Viewmodel Controller component. The latter is responsible for switching between UE4 and UE5 Mannequins, each of the Skeletons have unique animation sets and blueprints.
Character’s speed and gait are updated in Tick - Update Movement function:
Movement is updated every tick.
This function computes the character max speed and sets it via the Character Controller:
Speed update.
Here we also compute the Gait parameter - it is used in the animation blueprints to blend between idle, walk, sprint and tactical sprint states.
Gait update.
Because ViewmodelController is used as a data interface between gameplay and animation logic, the gait value resides in this component.Now it is time to find out how the weapon system works.