Equipment system¶
The equipment system puts an item in the character's hands. Selecting an item spawns its actor, attaches it to a hand socket, links the item's overlay poses (third and first person) and updates the hand IK targets. Items are described by data assets, so adding one needs no code.
| Folder | /GASPALS/Systems/EquipmentSystem |
| Component | AC_EquipmentSystem (on both pawns) |
| Data | Data/PDA_Equipment (class), Data/DA_Equipment_<Item> (one per item), Data/CHT_Equipment (chooser), Data/Enum_Equipment (slots) |
| Actors | Actors/BP_Equipment_<Item> |
| Menu | UI/W_Switcher_Equipment, UI/W_Button_Equipment |
| Input | T (hold for the menu), mouse wheel / D-pad to choose |
| Settings | Equipment reference |
Included items¶
| Slot | Actor | Third-person overlay | First-person overlay | Attach socket |
|---|---|---|---|---|
| Unequip | none | ABP_Overlay_Default | none | none |
| Rifle | BP_Equipment_Rifle | ABP_Overlay_Rifle | ABP_OverlayFirstPerson_Rifle | overlay_rifle |
| Pistol | BP_Equipment_Pistol | ABP_Overlay_Pistol2H | ABP_OverlayFirstPerson_Pistol2H | overlay_pistol |
| Bow | BP_Equipment_Bow | ABP_Overlay_Bow | ABP_OverlayFirstPerson_Bow | overlay_bow |
| Torch | BP_Equipment_Torch | ABP_Overlay_Torch | none | overlay_torch |
| Binoculars | BP_Equipment_Binoculars | ABP_Overlay_Binoculars | none | overlay_binoculars |
| Box | BP_Equipment_Box | ABP_Overlay_Box | none | overlay_box |
| Barrel | BP_Equipment_Barrel | ABP_Overlay_Barrel | none | overlay_barrel |
The rifle, pistol and bow are skeletal meshes with HandIK and ADS sockets; the bow animates its string while you aim (Bow_AnimBP, driven by the actor's Draw value). The others are static meshes.
How it works¶
flowchart LR
Sel[SelectedEquipment<br>Enum_Equipment] --> Ch[CHT_Equipment<br>chooser]
Ch --> DA[DA_Equipment_Item<br>PDA_Equipment]
DA -->|Overlay Pose TP| L1[LinkAnimClassLayers<br>third-person mesh]
DA -->|Overlay Pose FP| L2[LinkAnimClassLayers<br>first-person meshes]
DA -->|Spawned Actor| Sp[Spawn actor<br>attach to socket]
Sp --> IK[UpdateHandIK<br>IK_* transforms]
IK --> ABP[Character Anim Blueprints<br>CR_Humanoid_HandIK] When Selected Equipment changes (UpdateEquipment):
- The previous item's actor is destroyed.
CHT_Equipmentturns the slot into its data asset (fallbackDA_Equipment_Unequip).- Overlay Pose TP is linked on the pawn's third-person mesh; Overlay Pose FP on the first-person meshes. An empty Overlay Pose FP resets the first-person layers to their defaults.
- If the data asset has an actor class, the actor is spawned (owned by the pawn) and attached to the visible third-person mesh at Attach Socket TP, with Attach Offset TP.
- The actor's
AC_FirstPersonRenderingcreates a first-person copy of its mesh, which is attached to the first-person mesh at Attach Socket FP with Attach Offset FP. Meshes taggedDoNotAttachare left where they are. UpdateHandIKcomputes the hand targets. It runs for every slot, so after Unequip (no actor) the hand IK transforms are reset instead of keeping the previous item's values.
Hand IK¶
Two sockets on the item mesh place the hands:
| Socket | Use |
|---|---|
HandIK | Where the support hand grips the item. |
ADS | The sight point, lined up with the eye when aiming down sights in first person. |
UpdateHandIK stores six transforms (IK_HandLeft, IK_HandRight, IK_ADS and their _FP versions), each expressed relative to the hand that holds the item, so they follow it. The character Anim Blueprints (and the retarget and first-person Anim Blueprints) read them and run CR_Humanoid_HandIK. The hand IK weight comes from the overlay pose's enable_handik_l / enable_handik_r curves, so each pose decides when the support hand grips. Items without a HandIK socket (torch, box, barrel) rely on their overlay pose alone.
The bow moves its sockets as it draws, so it updates the hand IK every frame.
Sockets on the character¶
The items attach to overlay_* sockets on the character's Skeleton: overlay_rifle, overlay_pistol, overlay_bow, overlay_torch, overlay_binoculars, overlay_box, overlay_barrel. On the UEFN mannequin they hang from weapon_r / weapon_l; on the UE5 and MetaHuman skeletons from hand_r / hand_l. Retargeted characters need them on their own skeleton (see Add a retargeted character).
The menu¶
Hold T: the world slows to 0.35 speed and W_Switcher_Equipment opens with one button per Enum_Equipment value. Scroll (mouse wheel, D-pad) to move the highlight; release T to equip it. A new enum value appears in the menu automatically.
If the pawn is destroyed while the menu is open, the component's EndPlay calls CloseEquipmentMenu: it removes the menu widget and sets the world speed back to normal.
Cleanup¶
When the pawn is destroyed, DestroySpawnedActors (bound to the pawn's On Destroyed) destroys the item actor.
Data asset fields¶
PDA_Equipment:
| Field | Use |
|---|---|
| Spawned Actor | Actor class to spawn. Empty for Unequip. |
| Overlay Pose TP | Overlay Anim Blueprint linked on the third-person mesh (a child of ABP_OverlayPose_Base). |
| Overlay Pose FP | First-person overlay Anim Blueprint (a child of ABP_OverlayFirstPerson_Base). Optional. |
| Attach Socket TP / FP | Socket on the visible third-person / first-person mesh. |
| Attach Offset TP / FP | Transform relative to the socket. |
| Is Left Handed | The ADS target follows the left hand (the bow). |
Settings¶
AC_EquipmentSystem has one setting: Selected Equipment (category GASPALS > Equipment > Selection), the item the pawn starts with (Unequip on both sample pawns). Everything else is runtime state.
Using equipment from Blueprints¶
| Call | Use |
|---|---|
SelectNewEquipment(Slot) | Equip a slot. Call it on the owning client or the server; it replicates. |
SelectedEquipment | The current slot. |
SpawnedActor | The current item actor. |
EquipmentData | The current data asset. |
GetHandIK(Socket, TargetBone, bFirstPerson) | A socket of the item in a hand bone's space. |
Networking¶
Selected Equipment is replicated with a RepNotify. The owning client sets it and sends it to the server with one reliable RPC; every machine spawns and attaches its own copy of the item in the RepNotify.
Limitations¶
- The menu slows the whole world (also on a listen server host) while it is open.
- The torch, binoculars, box and barrel have no first-person overlay pose.