Skip to main content

Gameplay Abilities System Integration

Bolt integrates directly with the Gameplay Abilities System plugin. We support:

  • Using gameplay abilities to move items (including predictively) or crafting.
  • Ability costs that destroy items (e.g., for consumable items).
  • Dropping items from abilities (including predictively).

Abilities Granted By Items

Items may grant abilities when equipped, deposited, etc. To do so, the ability should derive from BLGameplayAbility_FromItem. This subclass gets notified of the item that granted it.

note

For abilities granted by items, the ability must have InstancingPolicy: InstancedPerActor.

Consumables

Consumable items are destroyed when used. For example, a health potion. You may think of consumables as having two parts: they grant an ability, and that ability costs one of the items to activate. We went over granting the ability in the above section; here we will go over ability costs.

Similar to ability costs from the Lyra Example, Bolt includes a BLAbilityCost class for assessing ability costs. We've also included a BLAbilityCost_DestroySourceItems which destroys items from the source item stack. This cost will only work for BLGameplayAbility_FromItem subclasses (i.e., abilities that were granted by items). Many games will already have an AbilityCost class implemented, so feel free to reparent BLGameplayAbility_FromItem to your own class.

See the GA_UseConsumable ability and IS_Consumable classes in the example map.

Using Abilities To Move Items

Bolt also supports using gameplay abilities to move items between inventories. This functions the same as the BLInventoryControllerComponent: to handle RPCs, prediction, etc., when players request to move items.

To do this, bolt includes an BLOperationAbilitySystemComponent that also implements BLInventoryController.

The operation ability system component needs a BLOperationAbility for each operation: e.g., Transfer (Slot to Slot), Swap Items From Slots, etc. The control flow looks like this:

  1. Button::OnClick calls OperationAbilitySystemComponent::Request_TransferSlotToSlot
  2. Send gameplay event with GameplayEvent.Bolt.TransferSlotToSlot tag and request parameters
  3. Event triggers GA_TransferSlotToSlot; sends activation RPC to the server
  4. Both the client instance and the server instance of GA_TransferSlotToSlot call Local Transfer (Slot to Slot).
    • The client instance causes predictive changes.
  5. GA_TransferSlotToSlot calls DispatchOperationResult with the result from Local Transfer (Slot to Slot).
    • This sends any errors back to the OperationAbilitySystemComponent.
  6. GA_TransferSlotToSlot finishes; Request_TransferSlotToSlot returns the result it received from GA_TransferSlotToSlot.
  7. The widget receives the result from Request_TransferSlotToSlot and tells the player controller to send feedback if it failed.

Here's an implementation from the example map:

Inventory Ability

  • We pass parameters through custom target data structs in the gameplay event. For this ability, it's called BLTargetData_TransferSlotToSlot.
  • Local Transfer (Slot to Slot): Moves the items; predictively if on client and the ability is LocalPredicted. On the server's version of the ability, it moves the items authoritatively.
  • Dispatch Operation Result: Sends the result from transfering items back to the ability system component. This ensures the caller has the correct result when the Request Transfer (Slot to Slot) function returns.
  • Cancel Ability: Operation abilities treat cancelling as failing to move items. When the client receives a Cancel rpc back from the server, it rolls back the associated predictions.

See the abilities in the Bolt > Gameplay > Abilities > Inventory folder in the example map.

Prediction

To support client-side prediction, the ability must have Net Execution Policy: Local Predicted.