Knockdown and Recovery
This guide shows how to configure knockdown and recovery for combatants.
Knockdown is an optional fatal damage reaction. When enabled, fatal damage can place a combatant into a temporary knocked down state instead of immediately starting the normal death flow. The combatant can then recover through a Gameplay Event, or die if the knockdown duration expires.
For more information, see Damage Reactions and Vulnerable States.
Prerequisites
Collision and Components
Your collision channels, combat components, Ability System setup, and base character setup should already be configured. For more information, see Combat Setup and Combat First Steps.
Damage Pipeline
The combatant must use a Damage Data asset through its Damage Manager or Combat Manager. This asset defines the damage outcome pipeline used to resolve fatal damage as knockdown.
Animation Assets
Knockdown usually uses three animation-related pieces:
An Animation Blueprint that can react to the knocked down state.
A Knock Down Montage that plays when the combatant enters knockdown.
A Recovery Montage that plays when the combatant recovers.
Configure the Animation Instance
Create an Animation Blueprint using
NinjaCombatAnimInstanceas the base class.In your Anim Graph or state machine, use
bKnockedDownto blend into and out of knocked down animation states.Make sure your Animation Blueprint has a full-body Slot that can be used by the knockdown and recovery montages.
Create the Knockdown Montages
Create an Animation Montage for the transition into knockdown.
Create an Animation Montage for the recovery animation.
Set both montages to use the full-body Slot configured in your Animation Blueprint.
Adjust blend times as needed so the transitions into and out of the knocked down state feel smooth.
Movement Component
If your character should move differently while knocked down, use a movement component that can react to the combat state.
Ninja Combat provides NinjaCombatCharacterMovementComponent, which can listen to combat state changes and adjust movement settings such as walk speed.
Configure Knockdown Movement
Open your Character Blueprint or base character class.
Select the Movement Component.
Configure the movement settings used while the character is knocked down.
For more information, see Combat Components.
Knockdown Abilities
Knockdown uses two Gameplay Abilities:
-CombatAbility_KnockDown, which handles entering the knocked down state. - CombatAbility_KnockDownRecovery, which handles recovery.
Configure the Knock Down Ability
Create a Gameplay Ability Blueprint using
CombatAbility_KnockDownas the base class.Set the Default Animation Montage to the knockdown montage created earlier.
Keep the default Knocked Down State Effect Class, or assign a custom effect based on
CombatEffect_KnockedDown.Keep the default Dead Effect Class, or assign a custom death effect used when the knockdown duration expires.
Grant this ability to the combatant.
Configure the Knock Down Recovery Ability
Create a Gameplay Ability Blueprint using
CombatAbility_KnockDownRecoveryas the base class.Set the Default Animation Montage to the recovery montage created earlier.
Keep the default Recovery Effect Class, or assign a custom effect based on
CombatEffect_RecoverFromKnockDown.Grant this ability to the combatant.
Knockdown Attributes
The default knockdown flow uses two Gameplay Attributes:
Attribute | Description |
|---|---|
| Defines how long the combatant can remain knocked down before dying. |
| Defines how much health is restored when recovering from knockdown. |
Both values must be greater than zero for the default Knock Down outcome to resolve fatal damage as knockdown.
Configure Knockdown Attributes
Open the attribute initialization table assigned to your combatant.
Set
NinjaCombatAttributeSet.KnockDownDurationto a value greater than0.Set
NinjaCombatAttributeSet.KnockDownHealthPercentto a value greater than0.
Damage Setup
The combatant must opt into knockdown through its Damage Data and Combat Manager configuration.
Configure Knockdown Damage Resolution
Open the Damage Data asset assigned to the combatant.
Add the Knock Down Damage Outcome to the damage outcome pipeline.
Make sure the Damage Data asset is assigned to the combatant's Damage Manager or Combat Manager.
Open the combatant's Combat Manager.
Enable Can Enter Knockdown State.
Once this is configured, fatal damage can be redirected into knockdown instead of immediately starting the death flow.
Recovery
In this example, a Trigger Box is used to recover knocked down combatants that overlap it. You can use the same event flow from other systems, such as Ninja Interaction
Create a Recovery Volume
Create a Blueprint based on Trigger Box.
Create a function named
HasKnockDownEffectthat receives an Actor.In
HasKnockDownEffect, retrieve the Actor's Ability System Component.Create an active Gameplay Effect query that checks for
CombatEffect_KnockedDownas the effect definition.Return whether the Ability System Component has an active Gameplay Effect matching that query.
Create a function named
SendRecoveryEventthat receives an Actor.In
SendRecoveryEvent, check for authority and retrieve the Actor's Ability System Component.Send a Gameplay Event using the
Combat.Event.RecoverFromKnockDownGameplay Tag.In the Event Graph, bind to the collision component's On Begin Overlap event on authority.
When an Actor overlaps, call
HasKnockDownEffect.If the Actor is knocked down, call
SendRecoveryEvent.
Give Up
A knocked down combatant can also be forced into the death flow by sending the Combat.Event.GiveUp Gameplay Event. This can be used for player-controlled give-up actions, timers, AI behavior, or scripted events.
Trigger Give Up
Retrieve the knocked down combatant's Ability System Component.
Send a Gameplay Event using the
Combat.Event.GiveUpGameplay Tag.