How-To: Grant Abilities from Equipment
Goal: make a weapon bring its own abilities, have those abilities read the item that granted them, and have everything revoked cleanly on unequip.
IAbilitySystemInterface.1. Make sure the ASC can be found
The plugin finds the ASC with Epic's UAbilitySystemGlobals::GetAbilitySystemComponentFromActor on the component's owner, which honors IAbilitySystemInterface. Any ASC works - Epic's, yours, or one on a PlayerState - as long as that interface returns it from the pawn.
LogCrimsonEquipment warns that the grants were skipped. Nothing errors and nothing tells the player. When gear silently grants nothing, check this first.2. List the grants on the definition
The definition carries three engine-typed grant lists: GrantedAbilities (FCrimsonEquipmentAbilityGrant: ability class, level, optional input tag), GrantedEffects (FCrimsonEquipmentEffectGrant) and GrantedAttributeSets (FCrimsonEquipmentAttributeSetGrant). The manager grants them through the engine ASC on equip and revokes them with the stored FCrimsonEquipmentGrantedHandles on unequip. (CrimsonCore - requires all Crimson plugins) additionally honors AbilitySetsToGrant (ability-set data assets) through UCrimsonCoreEquipmentAbilitySetSubsystem; without CrimsonCore that list is ignored.
Open your definition's Class Defaults and fill Granted Abilities (ability class, level, input tag), Granted Effects and Granted Attribute Sets. That is the whole wiring - there is no code and no event.
showdebug abilitysystem) on the server: the granted abilities are on the pawn's ASC. Unequip and they are gone.3. Base your abilities on UCrimsonGameplayAbility_FromEquipment
When the manager grants an ability, it passes the UCrimsonEquipmentInstance as the ability spec's source object. UCrimsonGameplayAbility_FromEquipment turns that into two accessors, so a shared ability can read the specific item that granted it.
| Node | Returns | What it gives you |
|---|---|---|
| Get Associated Equipment | UCrimsonEquipmentInstance* | The instance that granted this ability. Cast to your instance subclass for per-item state. |
| Get Source Object | UObject* | That instance's source object - your inventory item, if one was passed to Equip Item. |
Right-click in the Content Browser -> Add -> Crimson Plugins -> Equipment -> Ability From Equipment to create a Blueprint child. In its graph, Get Associated Equipment -> Cast To your instance class, then read whatever per-item state you keep there.
Add the ability to the definition's Granted Abilities (step 2) rather than granting it directly, so it is revoked with the gear.
Non Instanced abilities have no ability spec to read, so Get Associated Equipment cannot work. The class validates this at author time: a Non Instanced child fails data validation with a message saying so. Use Instanced Per Actor or Instanced Per Execution.Get Associated Equipment reads the current ability spec. Called outside an active activation it returns null and logs a warning to LogCrimsonEquipment. Read it inside ActivateAbility and cache what you need.4. Understand when grants are revoked
Grant handles live on the equipment entry, not on the pawn. Unequip Item calls Take From Ability System for that entry before the entry is removed, so exactly the abilities that item brought are revoked and nothing else.
| Situation | What happens to the grants |
|---|---|
Unequip Item | Revoked from the ASC, then the entry is removed. |
| Equipping into an occupied slot | The incoming item is granted first, then the displaced item is revoked - so a shared resource is never briefly unowned. See Concept: Slots and Displacement. |
Swap Equipped Items / Move Equipped Item To Slot | Nothing is revoked or re-granted. Both only change slot assignments. |
| The component is torn down | The server force-unequips everything, which revokes the grants. |
Restore From Save Data | Everything currently equipped is force-unequipped (revoking its grants) before the saved entries are re-added and granted. |
FCrimsonAppliedEquipmentEntry::GrantedHandles is marked NotReplicated. Grants exist only on the machine that has the ASC authority, which is what GAS expects - clients see the effects of the abilities through normal GAS replication, not through this list.showdebug abilitysystem on the server shows B's abilities and none of A's, and at no point during the swap were the shared ones missing.See also
- How-To: Add Per-Item Logic
- Concept: Slots and Displacement
- API Reference