Adding a pistol aim offset to the ALS (Advanced Locomotion System) Anim BP involves several steps, primarily modifying the existing upper body animation logic to account for a different weapon type.
ALS is highly modular, so we'll integrate the pistol aiming into its layered blend system.
Here's a step-by-step guide:
Prerequisites:
- Pistol Aim Offset Asset: You must have an Aim Offset asset specifically for your pistol.
- This usually requires a base pistol idle animation (in-place, aiming straight forward).
- Then, create an Aim Offset based on that animation.
- Populate it with directional poses (Up, Down, Left, Right, Diagonals) to create the aiming cone.
- Crucial: Ensure the base pose for this Aim Offset has the character holding the pistol correctly in the right hand.
- Pistol Equip/Unequip Animations: If you want specific equip/unequip animations for the pistol.
- Pistol Mesh: Your actual pistol skeletal mesh, ready to be attached to the character's hand socket.
Steps to Integrate Pistol Aim Offset into ALS:
We'll primarily be working in the ABP_Mannequin_Character (or your derived ALS Anim BP).
Step 1: Create a WeaponType Enumerator (if not already existing)
This is the cleanest way to manage different weapon types.
- In the Content Browser, right-click ->
Blueprints -> Enumeration.
- Name it something like
E_WeaponType.
- Open it and add entries:
None (for unarmed)
Rifle (for the default ALS aiming)
Pistol
- (Add others like
Shotgun, Melee, etc., if needed)
- Save the Enumeration.
Step 2: Add WeaponType Variable to ALS Anim BP
- Open your ALS Anim BP (
ABP_Mannequin_Character).
- In the
Anim Graph, My Blueprint tab, click + Variable.
- Name it
WeaponType.
- Change its type to your newly created
E_WeaponType and set its default value to None or Rifle.
Step 3: Integrate Pistol Aim Offset into the Upper Body Graph
This is the core of the animation logic.
-
Navigate to the Anim Graph in your ALS Anim BP.
-
Find the UpperBody section. This is usually a Layered Blend Per Bone node.
-
Inside or leading into this Layered Blend Per Bone, you'll typically see a sequence of nodes that calculate the AimOffset based on AimYaw and AimPitch.
- Find the current Aim Offset node: There will be an
Aim Offset node (or a Blend Poses by Aim Offset node) that takes AimYaw and AimPitch as input and likely outputs to an Apply Additive or directly into the Layered Blend Per Bone.
- Add your Pistol Aim Offset: Drag your pistol Aim Offset asset from the Content Browser into the Anim Graph. Connect
AimYaw and AimPitch to it.
-
Use Blend Poses by Enum to switch between Aim Offsets:
- Right-click in the Anim Graph and search for
Blend Poses by Enum.
- Set the
Enum input to your E_WeaponType enumeration.
- Connect the
WeaponType variable from your Anim BP to the Active Value pin of the Blend Poses by Enum node.
- Now, you'll have an input pin for each enum value (None, Rifle, Pistol, etc.).
- Connect the output of your existing Rifle Aim Offset (or the general
AimOffset node) to the Rifle pin.
- Connect the output of your new Pistol Aim Offset to the
Pistol pin.
- Connect the output of this
Blend Poses by Enum node to wherever the original Aim Offset was feeding into (likely an Apply Additive node or directly to the Layered Blend Per Bone).
(See image for conceptual node arrangement)
-
Adjust Layered Blend Per Bone (if needed):
- Ensure the
Layered Blend Per Bone node's Blend Mode is Additive for the aim offset layer.
- Make sure the
Blend Bones are set up correctly, usually starting from spine_01 upwards, to only affect the upper body. ALS usually handles this well by default.
Step 4: Handle Left Hand IK for Pistols
ALS uses sophisticated IK for the left hand to grip weapon foregrips. For a pistol, the left hand should typically relax or go to a specific pistol support pose, not try to grip an imaginary foregrip.
- In the
Anim Graph, find the section dealing with Left Hand IK. This is often within a custom graph or a sequence of nodes that calculate Hand_L_Location and Hand_L_Rotation for the TwoBoneIK node.
- You'll need to disable or modify the Left Hand IK when
WeaponType is Pistol.
- A common way is to use a
Blend Poses by Enum or a Blend Poses by Bool (checking if WeaponType == Pistol) to switch between:
- When Rifle/Other: The standard ALS left hand IK logic.
- When Pistol:
- Either
Disable the Left Hand IK (often done by setting the Alpha of the TwoBoneIK node to 0).
- Or, blend in a specific relaxed left hand pose or a pistol support pose (as an additive animation or a specific full body pose) for the left hand.
- You might need a specific "Pistol Left Hand Relaxed" animation and blend it in, or just let the base pistol idle handle it.
- A simple way is to use a
Select Float or Blend Poses by Enum to set the Alpha of the Left Hand IK to 0.0 when WeaponType is Pistol.
Step 5: Update the Character Blueprint (or Weapon System)
Your character BP (e.g., BP_Mannequin_Character) needs to communicate to the Anim BP what weapon is currently equipped.
-
Open your BP_Mannequin_Character Blueprint (or your custom character BP).
-
Wherever you equip/unequip weapons (e.g., on a EquipWeapon function, or when spawning a new weapon):
- Get a reference to the
Mesh component.
- Drag off the
Mesh and search for Get Anim Instance.
- Cast this to your ALS Anim BP (
ABP_Mannequin_Character).
- From the Cast node's
As ABP Mannequin Character pin, drag off and Set Weapon Type (your variable from Step 2).
- Set it to
E_WeaponType::Pistol when a pistol is equipped, and E_WeaponType::Rifle (or None) otherwise.
-
Attach the Pistol Mesh: Ensure your pistol skeletal mesh is attached to the hand_rSocket on your character's skeletal mesh.
Step 6: Refine and Test
- Compile and Save all Blueprints and Assets.
- Play in Editor:
- Test equipping/unequipping the pistol.
- Move around.
- Aim in different directions (up, down, left, right).
- Observe the left hand behavior.
- Adjust Blending: If transitions are too abrupt, adjust the
Blend Time in the Blend Poses by Enum nodes.
- Additive Poses: For more advanced control, you might have an additive pose for the general "pistol stance" (slightly different shoulder rotation, etc.) that you apply before the aim offset, blending it based on
WeaponType. This gives you a better base for the aim offset.
Conceptual Node Setup in Anim Graph (Upper Body Section):
|
V
(Aim Yaw) ----+ +----------------------+
| | |
(Aim Pitch) --+----------------+----------------> [Your Pistol Aim Offset Asset]
| | (e.g., AO_Pistol)
| | |
[Original Rifle Aim Offset]--+-------------------+ |
(e.g., AO_Rifle) | | |
| | |
V V |
[Blend Poses by Enum] |
(Enum: E_WeaponType) |
(Active Value: WeaponType) |
+-----------------------+ |
| None -> (Empty Pose) | |
| Rifle -> (Rifle AO) <--------------------------+
| Pistol -> (Pistol AO) <--------------------------
| ... |
+-----------------------+
|
V
[Apply Additive] (Optional, or direct to Layered Blend)
|
V
[Layered Blend Per Bone] (Your main UpperBody node in ALS)
By following these steps, you should be able to successfully integrate a pistol aim offset into your ALS-based character. Remember that precise adjustments to blending and IK might be necessary based on your specific animations and character rig.