# Physical Reactions

> Physical reactions move a character's bones under physics when a blow lands and drop the body limp when it dies: named reactions in a set, played from a hit or a Blueprint.

Markdown version of https://rigbak.com/docs/universal-player-combat/physical-reactions, a page of the Universal Player Combat documentation. Link that page when citing it.

## Set it up (5 minutes)

1. **Create a reaction set**

   Create the asset: right-click in the Content Browser, choose **UPC > Damage and Defense > Physical Reaction Set**, and name it **PhysReact_MyEnemy**.

   *Right-click in the Content Browser, UPC, Damage and Defense, Physical Reaction Set.*
2. **Add a flinch**

   This flinch moves bones under physics and leaves the character's attack and actions alone; stopping the attack is the [Hit Reactions](https://rigbak.com/docs/universal-player-combat/hit-reactions) ability, and both can run on one hit.

   The enemy's skeletal mesh needs a Physics Asset with bodies on the bones a reaction names; the demo mannequin's has them. Set **Authoring Mesh** to that mesh so the bone fields offer a dropdown, add a row to **Reactions** with two **Regions**, and set the fields below.

   In **PhysReact_MyEnemy** set:

   | Property | Value |
   | --- | --- |
   | Authoring Mesh | SKM_UPC_Manny_Simple |
   | Reaction Name | Flinch (replaces None) |
   | Regions | 2 Array elements (replaces 0 Array elements) |
   | Regions > [0] Root Bone | spine_01 (replaces None) |
   | Regions > [0] Peak Blend Weight | 0.65 (replaces 0.5) |
   | Regions > [1] Root Bone | neck_01 (replaces None) |
   | Regions > [1] Peak Blend Weight | 1.0 (replaces 0.5) |
   | Regions > [1] Start Delay Seconds | 0.03 (replaces 0.0) |
   | Push Bone | head (replaces None) |

   *Region [0] is the upper body; region [1] the neck and head. A body two regions share takes the larger weight, so the neck and head move at 1.*
3. **Give the enemy the component**

   Add **UPC Physical Reaction** to the enemy's Blueprint and set its **Reaction Set** to `PhysReact_MyEnemy`. An empty **Mesh Component Tag** drives the actor's main skeletal mesh.

   **Details panel: UPCPhysicalReaction** (component, in BP_MyEnemy)

   **Category: UPC > Physical Reaction**

   | Property | Value |
   | --- | --- |
   | Reaction Set | PhysReact_MyEnemy |
   | Mesh Component Tag | None |
   | Respect Physics Budget | true |
   | Replicate Orders | true |
   | Manage Mesh Collision | true |

   *Nothing moves until something orders a reaction or a fall, and the component costs nothing while nothing runs. Manage Mesh Collision sits under the advanced arrow.*
4. **Play it when a blow lands**

   In `Damage_MySword`, the [damage config](https://rigbak.com/docs/universal-player-combat/damage-and-hit-effects#what-a-landed-hit-does) from Melee Trace, add **UPC Play Physical Reaction** to **Hit Effects**.

   In **Damage_MySword**, under Hit Effects, new row (UPC Play Physical Reaction), set:

   | Property | Value |
   | --- | --- |
   | Reaction Name | Flinch (replaces None) |
   | Force | 2000 (replaces 0) |

   *Force 2000 snaps the head back like a punch.*
5. **Press Play and strike the enemy**

   Within 25 m of the camera (the default **Min Quality**, see the budget below), the enemy's head snaps back and the chest follows while its legs keep walking, then the bones return to the animation.

---

## How a reaction moves the body

A reaction is a list of **Regions**. A region takes hold at its **Root Bone** and moves every physics body under it, rising from the animation to its **Peak Blend Weight** (0 animation, 1 physics), holding, and easing back. **Push Bone** takes the blow's push wherever it landed; None pushes the struck bone.

**Timeline: Flinch** (0.5 s long). Tracks:

- **spine_01**: Lower Spine, 0.65 (0 s to 0.41 s, rising until 0.06 s)
- **neck_01**: Neck And Head, 1 (0.03 s to 0.44 s, rising until 0.09 s)

*Each bar is a region, from its start until its bones are back on the animation; the dashed rise is its Attack Seconds. Starting the neck a little after the spine sends the blow up the body.*

A region with **Phys Anim Profile** None hangs loose on the Physics Asset's joints; name a profile from the Physics Asset to make it resist.

---

## Play a reaction

- **From a hit**, as in the quick start: the push follows the path the weapon swept into the body, so a slash across the left shoulder throws the body to its right. The effect skips a target without the component, and 0 **Force** plays the reaction with no push. A dead body (Can be Damaged off) stays still unless the effect has **Run on Inert Hits** ticked.
- **From a Blueprint:** **Play Reaction** takes a name, the struck bone and a push; **Play Reaction for Hit** reads the bone and point off a hit result. Both return a handle for **Stop Reaction**; **Stop All Reactions** ends them all. **On Physical Reaction Started** and **Ended** bracket each one, for a sound or a camera shake.
- **From a paired action:** its **Ragdoll** event ([Paired Actions](https://rigbak.com/docs/universal-player-combat/paired-actions)).

---

## Drop the body when it dies

Nothing starts a ragdoll on its own. On a character built on the UPC Character Base, **On Damage Taken** tells you a hit emptied health, and **Start Default Ragdoll** drops the body with the set's **Default Ragdoll**:

Blueprint graph, nodes in reading order:

- **Comment box: BP_MyEnemy · Event Graph**

  - **Event On Damage Taken** (event); outputs: Damage Info, Result
  - **Break UPCDamage Result** (break struct); inputs: UPCDamage Result; outputs: Damage Applied, Additional Vital Damage Applied, Was Fatal, Result Tags
  - **Branch** (branch); inputs: Condition; outputs: True, False
  - **Find Physical Reaction Component** (pure function); inputs: Actor = self; outputs: Return Value
  - **Start Default Ragdoll** (function; Target is UPC Physical Reaction); inputs: Target, Impulse Bone = None, Impulse = 0, 0, 0; outputs: Return Value

The graph passes no push: the killing blow's own **UPC Play Physical Reaction** runs after **On Damage Taken**, so its push throws the falling body the way the blow went.

**Start Ragdoll** takes settings of its own for a knockdown or a special death; both take a push, and a body already falling keeps its fall. **Stop Ragdoll** snaps the skeleton back to the animation, so call it as the body is hidden or removed. **On Ragdoll Phase Changed** reports **Simulating**, **Settling** and **Settled** (no part moved 5 cm for a second, or 15 s after the fall), the moment for a dissolve or a despawn; **Settle Ragdoll** forces it early.

---

## Keep a big fight inside its budget

**UPC Physics Budget** caps a level at 8 moving ragdolls and 24 reactions; an order past the cap is refused without cutting anything running, and a ragdoll counts until it rests. **Min Quality**, a field on each row under **Reactions**, sets how far from the camera that reaction still plays; **Off** means no distance limit. A flinch that should play past 25 m needs **Reduced** or **Off**:

| Min Quality | Plays within |
| --- | --- |
| **Full** (the default) | 25 m of the camera |
| **Reduced** | 120 m |
| **Off** | Any distance, a dedicated server included |

Ragdolls play at any distance. The `UPC.Physics` console variables hold these numbers, and `UPC.Physics.ForceQuality` (-1 by distance, 0 Full, 1 Reduced, 2 Off) forces one detail. **Set Limits**, called from the game mode, gives a level its own caps; untick **Respect Physics Budget** on a boss whose death must fall however busy the level is.

---

## Debug it

**On Physical Reaction Refused** fires with the reaction's name and a reason; bind it while building content. `LogUPCPhysicalReaction` warns once per setup mistake, such as a bone with no physics body or a profile missing from the Physics Asset; at Verbose it also reports budget and distance refusals. Saving a set checks every name against its Authoring Mesh. `stat UPCPhysics` counts the regions, bodies and ragdolls running and the orders refused.

<details>
<summary>Every region setting (Advanced)</summary>

| Setting | Does |
| --- | --- |
| **Whole Body**, **Excluded Bones** | Take every body on the mesh; or leave parts on the animation by their top bone, such as both collar bones to keep a two-handed grip. |
| **Phys Anim Profile**, **Constraint Profile** | The Physics Asset motors that make the region resist, and a joint set to loosen a shoulder or stiffen a neck. |
| **Start Delay**, **Attack**, **Hold**, **Release Seconds** | When it joins, rises (under 0.02 s snaps), holds and eases back (under 0.1 s snaps). **Envelope** is a curve in their place; **Indefinite** holds the peak until stopped. |
| **Priority**, **Strength Scale** | On bones two regions share, the higher Priority's profile wins, then the later region. The largest Strength Scale sets the whole mesh's motors. |

- **Apply Impulse** pushes with the blow; **Impulse at Hit Location** lands it at the contact, adding spin (off for a shockwave); **Velocity Change**, with that off, moves a hand and a torso alike.
- **A second hit** on a moving body starts its regions at their peak from the pose shown and spreads its push over **Re-hit Blend** (0.12 s; 0 pushes at once). A standing body at rest takes it at once.
- A **Root Bone** without a physics body works while one hangs below it. The pelvis, the root body, moves only in a ragdoll, so a region on it moves the spine and legs.
- Joined bodies return to the animation together, so a chain does not pop.

</details>

<details>
<summary>Ragdoll settings (Advanced)</summary>

| Setting | Does |
| --- | --- |
| **Root Bone**, **Whole Body** (on), **Excluded Bones** | What goes limp; a lower root costs less. |
| **Constraint Profile** | The joint set while limp: limits, and Orientation Drives pulling toward a relaxed pose. The demo's is **Ragdoll**. |
| **Starting Tension** (1), **Tension Fade** (0.8 s) | How much pull the fall starts with and how long it eases away; 0 keeps it until the body rests. |
| **Blend in Seconds** (0.05) | A partial ragdoll's hand-over; a whole-body fall goes limp at once. |
| **Collision Profile** | `Ragdoll` while limp, the camera's view of the mesh unchanged; put back on Stop Ragdoll. |
| **Settle Policy** | Once the body settles: **Keep Asleep** leaves it lying, **Stop Simulating** costs less but stands it back up. |
| **Carry Owner with Body** (on) | Move the character with the body; characters and the camera pass through it, swings still land. |
| **Body Fall Effect Speed** (120 cm/s) | How hard the pelvis must land to ask its anim effects once for `UPC.AnimEffect.BodyFall`, a body-fall sound. |

</details>

<details>
<summary>What every player sees (Multiplayer)</summary>

- A server order reaches every machine, and each runs its own physics, so bodies land in similar poses. **Play Reaction** on a client plays there alone.
- A flinch is one message packet loss can drop. A fall is replicated with its settings, so a later joiner finds the body down, collapsing at its resting place under **Late Join Drop** and standing there with it off. **Start Default Ragdoll** sends no settings, so keep one Reaction Set on every machine.
- With **Replicate Orders** on, the actor must replicate, or it warns; untick it for single player.
- A dedicated server plays only Min Quality Off reactions but sends them all; **Settle on Dedicated Server** plays falls out there for joiners.
- Camera distance and **Stop Reaction** stay per machine; an order the server's budget refuses reaches no one.

</details>

<details>
<summary>C++</summary>

- `UUPCPhysicalReactionComponent` (`UPCFoundation`) drives the bones; `UUPCPhysicalReactionSet` holds `FUPCPhysicalReaction` rows of `FUPCPhysicalReactionRegion` regions and an `FUPCRagdollSettings`. `UUPCPhysicsBudgetSubsystem` is the per-world budget.
- The component implements `IUPCPhysicsImpulseReceiver`, so **UPC Apply Physics Impulse** pushes a ragdoll on every machine's copy.
- `UUPCPhysicalReactionHitEffect` (**UPC Play Physical Reaction**) runs target side, on the authority; `FindPhysicalReactionComponent` finds the component or a subclass on any actor.

</details>

<details>
<summary>Troubleshooting (Advanced)</summary>

| Reason | Fix |
| --- | --- |
| **Unknown Reaction** | No reaction by that name, or no Reaction Set. |
| **No Bodies to Move** | The region's bones carry no physics body, Excluded Bones took them all, or it covers only the pelvis. |
| **No Physics Asset** | Give the mesh one. |
| **Mesh Collision Has No Physics** | Turn **Manage Mesh Collision** back on, or set the mesh to Query And Physics. |
| **No Skeletal Mesh** | The actor has none, or **Mesh Component Tag** names none. |
| **Physics Bodies Not Ready** | The mesh is building its bodies, a frame or two after a spawn or mesh swap. |
| **Budget Full**, **Out Of Range** | The level is at its cap, or the character is too far for the reaction's Min Quality. |
| **Component Inactive** | Set Active switched the component off. |

</details>

---

Previous page: [Hit Reactions](https://rigbak.com/docs/universal-player-combat/hit-reactions). Next page: [Vitals](https://rigbak.com/docs/universal-player-combat/vitals)
