CombatBlock Ability
Last modified: 09 October 2024Applies the Block Gameplay Effect, which typically modifies attributes such as Block Chance and Block Amount.
Optionally checks for a cost, such as a stamina cost, required to initiate blocking.
Blocking events may trigger changes in the Animation and Movement systems.
In the Combat System, blocking is handled using a blocking state, represented by a Gameplay Effect and an effective angle. This means the blocking system does not rely on actual collisions but instead uses gameplay attributes to determine success.
When the Block Ability is activated, it applies the appropriate Blocking Gameplay Effect. The blocking logic in the Defense Component (usually, the Combat Manager) then activates, handling the core blocking functionality.
Blocking Calculation
When blocking is activated, several Gameplay Attributes become relevant. These attributes control the effectiveness of the block and its limitations.
Attribute | Description |
---|---|
| Chance to block an incoming attack, in a {0, 1} range. |
| Amount of damage mitigated by blocking, in a {0, 1} range. |
| Maximum angle within which blocking is effective. |
| Flat limit of damage that can be mitigated while blocking. |
| Stamina cost required to block each point of damage. |
| Cooldown applied after a successful block or when a breaker hit occurs. |
The Block Ability will always check the Stamina Cost Rate before activating, ensuring the combatant has the minimum required stamina (or other relevant resources) to block effectively.
Integrations
Blocking is frequently integrated with other systems within the Combat System, such as Movement, Animation, and Hit Reactions.
Movement
Blocking can affect movement, often reducing the character's movement speed to a walking speed. You can implement this by listening to the Defense Component's Blocking State Changed delegate, or by using the provided NinjaCombatCharacterMovementComponent
, which automatically handles movement adjustments during blocking.
Animation
When blocking, characters may switch to a different movement state, reflecting the defensive stance. You can track this state through the same delegate or by using the NinjaCombatAnimInstance
, which includes a Blocking
property to represent the current blocking state.
Here's an example showing how to use the 'Blocking' property to switch between animation sequences.
Here's another example, using a Chooser Table to select the correct Motion Matching database.
Hit Reactions
You can define custom hit reactions for blocked hits by creating a specific Animation Montage for when a character blocks incoming damage. Similarly, a different reaction can be triggered for breaker hits (when a block is interrupted).
Gameplay Tag | Context |
---|---|
| The hit was blocked. |
| The blocking stance was interrupted. |
Here's an example of a Hit Reaction Ability that includes blocked and breaker hits.