Posing Ragdolls

Overview

This feature allows using the Physics Tool in the Sandbox to pose ragdoll entities when the simulation is not running. Collisions and additional constraints are supported. The pose can then be used as a starting state for the Simulate Objects feature, or saved as a physics state directly.

Two IK modes are supported, one only minimizes kinetic energy change, and the other is a mix between energy minimization and pose preservation.

Since the Physics tool is used in its entirety in the PhysDebugger, the feature is available there as well.


Modes

There are two different modes:

Default mode

Measures the effects of each rotation angle on each body's velocity using vector sums, which makes it a precise estimate.

Stiff mode

In Stiff mode, each rotation is weighted assuming that its children are immovable, so it tends to preserve the pose more.

There is a command that can be added to toolbars for the Stiff mode called Use Stiff IK Mode. For more information about how to customize toolbars, see Customizing ToolBars.

Usage

To pose deadbody entities:

  1. Add a deadbody entity into the level from Create Object -> Legacy Entities -> Physics -> DeadBody (maybe add some geometry for it to fall onto if desired)
  2. Turn on Physics tool mode

    This toolbar is not displayed by default
  3. Enable the desired mode (Default or Stiff mode) by using the CVar ed_PhysToolIKStiffMode. For Default mode, set this to 0, for Stiff mode, set to 1.
  4. Move the deadbody around
    • Use Ctrl + LMB to drag the deadbody around and lock the dragged part's orientation.
  5. Each move is automatically saved as a physics state, as if Get Physics State were used.
  6. Choose Simulate Objects if the ragdoll is non-sleeping and you want to simulate it further. Once the ragdoll goes to rest it'll save its state.

Collisions and Constraints

The ragdoll's limbs will be moved if it collides with the terrain or objects.

It is also possible to add constraints, so that the ragdoll will not move that specific part of its body.

Use Shift + LMB to create point constraints or Shift + Ctrl + LMB for "full" constraints (position and rotation). Shift + Alt + LMB creates an Alignment constraint to align a bone with the surface that the normal of its largest bounding box's face points to. A common use of this constraint could be aligning a foot with the ground below it. This constraint only works on terminal bones.

Holding Shift while dragging will cancel the dragging as soon as any collision is encountered (note that Shift will have to be pressed after the LMB, since otherwise the LMB will create a constraint instead of entering drag mode). This can be useful if you want the ragdoll just touching something without trying to accommodate for the collision by pushing its bones back/aside, etc.


Constraints

CVars

The following CVars are related to this feature:

CVar/Command

Description

Comments

ed_PhysToolIKStiffMode

Selects the IK mode that is a mix of pose preservation and energy minimization.

0 = default mode, 1 = stiff mode.

ed_PhysToolIKPrec

The precision (i.e. allowed error) with which the constraints are resolved (this includes both fixed constraints and the drag constraints that you pick objects with).

In meters. It is recommended that this value be kept small, somewhere between 0.001 and 0.01.