Two Handed Weapon Wielding And Aiming Behavior.

(Coming Soon ----- Under Development)

Introduction:

This tutorial will cover the ways in which you can customize the 'Two Handed Wield' pose of your character.

The following will be covered:

0 - Pre-Requisites

1- Enabling Aiming Behavior

2 - Setting Custom Weapon Holding Positions

3 - Using The Trigger Hand Override

4 - Separating Look-At And Aiming Direction


What You Get: 



Examples of behaviour set up in this tutorial can be found on our demo map located here: 

0. Pre-Requisites:

1) Standard IKinema Rig + 2 hand tasks.
2) IKinema Foot Placement set up with look at behaviour.
3) One or more weapon skeletal meshes whose root is positioned such that it snaps to your characters hand bone with correct alignment.

1. Enable Aiming Behavior

In The Details Panel:

1) In your characters Animation Blueprint, select the foot placement node.
2) In the details panel navigate to the "Aiming Stance" section
3) Enable the "Aim With Weapon" bool.
4) Enable the "(As Pin)" bool for the "Aim Task" option to expose the pin on the blueprint node.
5) Select the 'Handle Bone' and 'Trigger Bone'
5a) The Handle bone should correspond to the hand which will grip the handle of the weapon – near the shooty end.
5b) The Trigger bone corresponds to the hand of the character which will grip the trigger end of the weapon.

Creating The Node:

1) Right-click in the background of the anim bluepint.
2) Search for and place a "Set up aiming task" in the animBlueprint.
3) Click and drag the return value of the "Set up aiming Task" node to the exposed "Aim Task" pin of the foot placement node.


Image 1: How the Setup Aiming Node Connects With The foot placement Node

 

4) Click on the Aiming Type drop-down menu and select "Two Hand Wield"

2. Setting custom weapon holding hand positions.

This behaviour is one of the staples of the aiming node. It allows for modifying the hand positions of a static aiming pose to suit any weapon regardless of size. This is done by automatically generating hand task positions based on socket locations defined on the weapon skeletal mesh based on where the characters hands should be.

Setting and Getting the "Trigger and Handle Socket" transforms:

The IKinema node uses sockets placed on the skeletal mesh of the characters guns to define where the characters hands should be. Using sockets means this is tuneable and changeable during runtime giving full control over hand placement.

We will assume a two weapon set up. We will need to define the handle and trigger sockets on each weapon to give us the correct holding stance.

Placing the sockets on the weapon skeleton:

1) Open the skeleton of your weapon mesh.
2) Right-click on the root bone and add two sockets.
3) Loosely position one of the sockets near the gun trigger and one on the barrel of the gun

These sockets are used to derive the positions of your characters hands.
In the picture below the sockets are shown and named "Trigger" and "Handle" respectively.


Image 2: Handle And Trigger Socket Attached To Weapon Skeleton

Image3: Handle And Trigger Socket Attached To Weapon Skeleton

 

The socket locations will depend on where you want the hands to be and the character mesh itself. The exact location will be dependent on your character. For this reason, it is not critical to get the perfect placement at this stage as once the behaviour is set up they can be tuned to perfections.

Storing the values in character blueprint:

In our character blueprint, on the begin play event, we can fetch the locations of the sockets set above in their "Parent Bone Space". The socket locations must be fetched each time the hand positions should be changed, for instance when switching weapons or if you want to change the current hand locations on the current weapon. We "Get Socket Transform" of the sockets we created in images 2 and 3 which were named "Handle" and "Trigger" in both.

Image 4: Getting And Storing Socket Transforms In Character Blueprint

 

Fetching stored values in animation blueprint:

The values can be fetched from your character blueprint in your characters animation blueprint as follows:

Image 5: Fetching The Needed Transforms In Character Blueprint

 

-With these variables stored in our animation blueprint, in the "Set up aiming task" node, feed the trigger and handle socket transforms to their respective pins as follows

Image 6 - Feeding The Socket Transforms To Aiming Node

 

-Ensure "Aiming Type" is set to "Two Hand Wield" and "Handle Hand Alpha" is set to 1.

 

Fine Tuning The Sockets:

Results:

 

3. Using The Trigger Hand Override

The trigger hand override can be used to offset the characters 'Trigger Hand'. It can be used in conjunction with the custom Handle hand position. This feature can be used to generate different aiming stances such as modifying an aiming pose to shoot from the hips or down scope.

Enabling Trigger Hand Override:

1) In the animation blueprint, select the 'Setup Aiming Task Node'. 

2) Tick the "Enable Trigger Hand Override"

With the above bool ticked, the solver will take the "Trigger Hand Override" transform and set this as the target of the "Trigger Hand" selected above. 

The solver expects the trigger hand override transform to be set by the user in the component space of the character. This can be easily done in the characters blueprint

Setting the Trigger Hand Override Transform In Character Blueprint:

Image 7: Setting and Storing Trigger Hand Override Transform In Character Blueprint

One way of doing so is to add a "Scene Component" in your characters blueprint and use this to define the Trigger Hand Offset. If this value is constant it only needs to be calculated once or it can be updated on the event tick if you wish to drive it. The nodes used above ensure the offset is calculated in the component space of the characters skeletal mesh component.

 

Setting The Trigger Hand Override In The Animation Blueprint

We fetch the trigger hand override transform in our animation blueprint in the same way we did the socket transforms in the previous section. 

Image 8: Fetching the trigger hand override transform from the character blueprint

 

We then feed this value to our 'Setup Aiming Task' node. 

 Image 9: Using the trigger hand override in the animation blueprint

Result: 

4 Separating Look At And Aiming Direction

The Aiming node will allow you to define a separate aiming location which is separate from the look at direction. With this feature enabled, the character can aim at one location while looking in another. 

In order to enable this behaviour:

1) In the 'Setup Aiming Task' node, tick the "Use Separate Aim Target" bool

2) Provide a vector which is the location of the aim target.

The aim target vector must be specified in either the component space of the character or in world space. The space the vector should match up with the 'In Component Space' bool found in the Foot Placement node.

If the 'In Component Space' bool is ticked, the 'Aim Target' vector should be supplied in component space. If the 'In Component Space' bool is unticked the 'Aim Target' vector should be provided in world space.

Result: