How-To: Grant an Ability Set
Goal: bundle abilities, gameplay effects, and attribute sets into one UCrimsonAbilitySet data asset, grant it to an ability system component, and revoke it later - including across plugins with no dependency on CrimsonAbilitySystem.
UAbilitySystemComponent (the GAS plugin is enabled). Granting must run on the server.1. Create and fill the ability set
Content Browser -> right-click -> Miscellaneous -> Data Asset, choose `CrimsonAbilitySet` as the class. Open it and populate three arrays: Granted Gameplay Abilities (each with an ability class, level, and input tag), Granted Gameplay Effects, and Granted Attributes (with optional per-attribute base-value overrides).
Images/CrimsonCommon/howto-abilityset-create.pngMaxHealth before Health so the cap is read first.2. Grant it (you hold the ASC)
If you already have the UAbilitySystemComponent, grant directly and keep the returned handles so you can revoke the exact same grant later.
Images/CrimsonCommon/howto-abilityset-grant.pngAbilities in the GAS debugger, or showdebug abilitysystem).3. Grant it across a plugin boundary
When the granting plugin must not depend on CrimsonAbilitySystem (e.g. CrimsonEquipment granting a weapon's abilities), don't reach for the ASC yourself. Cast the owner to ICrimsonAbilitySystemOwner and let it grant on its own component.
// In CrimsonEquipment - zero #include from CrimsonAbilitySystem:if (ICrimsonAbilitySystemOwner* Owner = Cast<ICrimsonAbilitySystemOwner>(OwnerActor)){FCrimsonAbilitySet_GrantedHandles Handles;Owner->GrantAbilitySet(AbilitySet, /*SourceObject*/ ItemInstance, &Handles);GrantedHandlesByItem.Add(ItemInstance, Handles);}
ICrimsonAbilitySystemOwner is the bridge interface (see Concept: Decoupling Patterns). UCrimsonAbilitySystemComponent in CrimsonAbilitySystem implements it; the equipment plugin only knows the interface. Note it has no GetAbilitySystemComponent() - the implementer owns its ASC and grants on it directly.4. Revoke it
Pass the stored handles back to remove everything the grant added - also server-only.
Call Revoke Ability Set (UCrimsonAbilitySetStatics) with the stored Granted Handles and the ASC. The handle set is cleared after removal so it can't be revoked twice.
See also
- Concept: Decoupling Patterns - the interface-bridge pattern in full
- API Reference -
UCrimsonAbilitySet,FCrimsonAbilitySet_GrantedHandles,ICrimsonAbilitySystemOwner