# Player Blueprint

## Basics

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:

<figure><img src="/files/H8wYukSTDJYcTLGN7Afi" alt="" width="416"><figcaption><p>BP_Viewmodel character.</p></figcaption></figure>

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*:

<figure><img src="/files/ofBrJ1TdvANXHcklCnRH" alt="" width="404"><figcaption><p>All events used by the character blueprint.</p></figcaption></figure>

{% hint style="success" %}
**Tip**: you will find all the main logic implemented in the Event Graph.
{% endhint %}

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:

<figure><img src="/files/9z6QTNEp0t3HYdIlfD3l" alt="" width="344"><figcaption><p>Reload action example.</p></figcaption></figure>

Now let's focus on the logic implemented by the **BP\_Viewmodel**.

## Initialization

Before the game starts, **BP\_Viewmodel** tries to add a custom Input Mapping Context to our Player Controller:

<figure><img src="/files/vFINlZKFvdKoWohQ7WS1" alt="" width="563"><figcaption><p>Adding Input Mapping Context.</p></figcaption></figure>

This will make sure our custom [Broken mention](broken://pages/DcsflKuyGtnOitimKxgh) are registered, so our gameplay actions can be executed. Next, we need to spawn the weapons:

<figure><img src="/files/1Dl4e7GVMeaFXqLMSvoJ" alt="" width="476"><figcaption><p>Weapon Manager handles weapon instantiating logic!</p></figcaption></figure>

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.

## Movement

Character's speed and gait are updated in **Tick** - `Update Movement` function:

<figure><img src="/files/1xHeTL9UKAQPNd62msf0" alt="" width="309"><figcaption><p>Movement is updated every tick.</p></figcaption></figure>

This function computes the character max speed and sets it via the **Character Controller:**

<figure><img src="/files/ohG09OeLQ9iReop7YMiC" alt="" width="295"><figcaption><p>Speed update.</p></figcaption></figure>

Here we also compute the **Gait** parameter - it is used in the animation blueprints to blend between idle, walk, sprint and tactical sprint states.

<figure><img src="/files/BZOfs6MFOQemCCzhTl7k" alt="" width="269"><figcaption><p>Gait update.</p></figcaption></figure>

Because **ViewmodelController** is used as a data interface between gameplay and animation logic, the gait value resides in this component.&#x20;

***

Now it is time to find out how the weapon system works.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kinemation.gitbook.io/fps-animation-pack-unreal/gameplay/player-blueprint.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
