On this page |
Overview
Sometimes you want to transition agents to a state where instead of being controlled by animation, they are controlled by rigid body simulation. For example, if an agent dies, you want it to fall to the ground, with its body and limbs being knocked about by collisions.
Setting up characters
First, you must add ragdoll-specific information to your character using tools on the Crowds shelf.
-
Use the Collision Layer tool to set up simple collision geometry around the agent’s skeleton.
Select the agent from the agent setup network (not from the crowd source network if you already have it).
-
Click a major bone.
-
Use the handle to adjust the collision shape size.
-
You can pick different simple shapes to wrap around bones, such as capsules or boxes.
Don’t add collision . For example, for the hand, you might use just a single sphere or box.
-
-
Use the Configure Joints tool to specify the range of motion for each joint. This is where you specify, for example, that a character’s elbow can’t bend backward.
Select the agent from the agent setup network (not from the crowd source network if you already have it).
-
Click a joint.
-
Use the handle to adjust the rotation limits of the joint.
-
You can set the limit to 0 in one direction to create a hinge (like an elbow or knee).
-
Creating named joint groups
You can create named groups of joints on the agent so you can apply ragdoll effects to some parts of the agent and not others.
-
In the geometry network that sets up the agents, find the Agent Transform Group node.
-
In the parameter editor, use the Transform groups multi-parm to create new groups. For each group:
-
Set the Name to the name of the joint group. For example,
upper_body
. -
In Root transforms, select the root joint(s) for the group. Each root and its descendents will be added to the group.
-
You can turn on Blend into group to get a ramp that controls how much effects applied to the group (such as stiffness, ) apply to the root vs the "outermost" joints.
-
You can turn on Show guide geometry to draw spheres around the selected joints (you can scale the spheres on the Guides tab). This makes it easy to see which joints are part of the group.
-
Testing
When you use the Collision Layer and Configure Joints tools, they create a TEST_RAGDOLL_SIM
node in the agent setup network. You can switch the display flag to this node and click Play in the playbar to play a simple simulation of the agent in ragdoll state with gravity.
The test node lets you give the agent an initial velocity, so you can test how it the agent reacts to when you throw it in different directions.
This node is also useful because if you have joint limits mistakenly set up so that the skeleton’s initial state is outside the limit, when you start the test sim, the joint will immediately pop, showing you where there’s a problem.
Ragdolls in DOPs
Ragdoll state
In a Crowd State DOP, you can choose to make agents in that state ragdolls using the RBD Ragdoll parameter.
Active
Agents are ragdolls controlled by the Bullet RBD solver.
Animated Static
Agents are controlled by the crowd solver, but can affect other dynamics objects (for example, kicking things around as they walk).
Ignore
Agents are controlled by the crowd solver, and not affected by rigid body dynamics.
Impact trigger
The Crowd Trigger DOP has an "RBD Impact Data" type that lets you trigger a transition when an agent is hit by an RBD object. For example, you could have agents change to ragdolls when they're hit by a boulder.
The node lets you specify a list of RBD objects that can activate the trigger, and how strong the impact must be for the trigger to activate.
Tip
To have agents be able to trigger based on colliding with other agents, set the crowd object as one of the DOP Impact objects.
Behind the scenes
When the Bullet solver sees ragdoll agents, it looks at the agent’s transforms, and treats each transform with a shape in the collision layer as a rigid body. At the end of each simulation timestep, it updates the agent’s transforms to account for the change in the simulated rigid bodies. It tries to sensibly adjust the agent’s position and orientation so the agent’s local transforms stay "in place".
Additional ragdoll effects
When the agent is in a state where RBD Ragdoll is "Active", you can apply effects such as Stiffness (resistance to animation/simulation), Partial ragdoll (part of the agent can be simulated while the rest follows an animation clip), and Motors (joints can be partially driven by an animation clip but still react to simulation forces). See the parameters on the Crowd State DOP for more information.
Detaching limbs (advanced)
-
The Agent Constraint Network node in the crowd source geometry network creates a set of polylines representing every constraint for every joint on every agent. The
ragdoll_constraints
Constraint Network DOP in the crowd simulation network solves this constraint network, applying forces to maintain the constraints.The
ragdoll_constraints
node has amodify_ragdoll_constraints
SOP Solver network attached that you can use to modify the constraints as part of the simulation. This is where you can delete constraint lines to detach limbs. -
If you have agents that are ragdoll (the RBD Ragdoll parameter on their state is "Active") or can potentially switch to ragdoll (RBD Ragdoll is "Animated static"), the ragdoll solver adds attributes to the constraints you can use to trigger constraint changes.
Right-click the
relationship_geometry
node in the SOP solver network and choose Spreadsheet to see the attributes. -
The
torque
primitive attribute contains the force the solver had to use to maintain the constraint in the current timestep. In other words, the amount of force on the joint.You can set up a primitive wrangle that deletes any constraint line where the
torque
is above a certain limit to detach limbs upon impact:if (f@torque > 50) removeprim(0, @primnum, /* andpoints */ 1);
-
If you have deforming geometry on the agent, the detached part will move away, but the skin will stretch over to it. You will need to switch to an alternate layer with separate skin geometry for detached agents.