On this page |
Parent-child relationships between agents can be set up using the Agent Relationship SOP. The Agent Relationship SOP adds attributes on the agents that describe the parenting relationships they have. These attributes are then used by the crowd solver and crowd motion path tools to keep the child attached to the parent.
Set up the parent-child relationship ¶
In this example, we attach rider agents (child) to horse agents (parent):


Child agents are attached to parent agents based on point number. It’s not necessary to have the same number of parent and child agents. If there are more child agents than parents, there will be multiple child agents attached to some parents.
By default, the Agent Relationship SOP updates the child’s overall transform to match the parent’s overall transform. There are a couple ways to further adjust the child agent once the initial attachment is made:
-
Enter the Agent Relationship viewer state by clicking
on the left toolbar, and adjust the child agent using the handle. To change the orientation of the child,
click the handle and select Cycle Translate/Rotate, or press Y over the viewport to change the handle to rotate mode. The Translate and Rotate parameters on the Agent Relationship SOP will be updated as you manipulate the handle:
-
Attach the child to a particular joint on the parent - on the Agent Relationship SOP, turn on Parent Joint, and select a joint on the horse to attach the rider to. You can also specify a joint on the child agent (in the Child Joint parameter) to attach to Parent Joint.
To... | Do this |
---|---|
Specify the agents that can be parents |
The Parent Group parameter will be populated with the selected parent agents. |
Attach a child agent to a specific parent agent |
|
Change the scale of the child to match the scale of the parent |
On the Agent Relationship SOP, turn on Match Parent Agent Scale. |
Crowd simulation network ¶
In the crowd simulation network, the crowd solver keeps the child agent attached to its parent, and the parent’s movement is steered by the forces applied to it. The crowd_simulation
DOP network from the parent SOP network is shown below:

-
On the
crowdobject
DOP, set Source to First Context Geometry because the Agent Relationship SOP in the parent SOP network is connected to the first input of thecrowd_simulation
DOP network node. -
Set the horse agent’s state:
-
Rename the horse agent’s Crowd State DOP, in our example,
horse_run_straight
. -
Set the animation clip that the horse plays in this state - on the Crowd State DOP, set Clip Name to
run_straight
. -
Set Type to Locomotive because the original clip has some overall root motion.
Note
To view the animation clips that are available on the agent, use an
Agent Clip SOP:
-
On the Agent Clip SOP, turn on Set Current Clip and select the animation clip you want to view from the drop-down menu. These animation clip names are used to set the clip that the state plays in the Crowd State DOP’s Clip Name parameter.
-
Click
in the playbar to play the clip. If the animation plays really fast, try clicking the
Real Time Toggle in the playbar.
-
-
Make the horse agents move around randomly using the
POP Steer Wander DOP:
-
Set Output Attribute to Crowds steerforce because we are working with agents and not particles.
-
-
Set the rider agent’s state:
-
Rename the rider agent’s Crowd State DOP, in our example,
rider_run_straight
. -
Set the animation clip that the rider plays in this state - on the Crowd State DOP, set Clip Name to
run
.
-
The parent and child agents are treated as separate agents with their own sets of animation clips (defined in their respective Crowd State DOPs). Any steering forces applied to the child agent will not have any effect on the child’s motion because it is attached to the parent.
Detach child agents ¶
There may be cases where you would want to detach a child agent from its parent. For example, if you want to transition a child agent to a full ragdoll, you would first detach the child from its parent.
The Agent Relationship SOP adds attributes on the agents that describe the parenting relationships they have. The attribute agentrel_parentid
on an agent identifies the parent agent it is attached to. If agentrel_parentid
is less than 0
, that agent does not have a parent, and its other agentrel_*
attributes are meaningless.
In this example, we detach the rider agent from its parent horse agent after 50 frames. We do this by adding a Crowd State DOP with the animation clip to play when the rider become detached, as well as the trigger condition that transitions the rider to the new animation clip:

-
The Crowd State DOP,
rider_detached
, is a copy of the Crowd State DOP,rider_run_straight
. -
Detach the rider from its parent using a
POP Wrangle DOP:
-
In the VEXpression field, write VEX code to set the
agentrel_parentid
attribute to-1
for the child agents you no longer want to be parented. For example, the following VEX snippet unparents all the child agents:i@agentrel_parentid = -1;
-
-
Use a
Crowd Trigger DOP to set the trigger that detaches the rider from its parent:
-
Set Type to Time (Current). By default, the trigger is activated when the number of frames is greater than 50 (based on the values of parameters Units, Comparison, and Playback Time).
-
-
Use a
Crowd Transition DOP to transition the rider to another state after detaching from its parent:
-
We want to transition the child from state rider_run_straight to rider_detached, so set Input State to
rider_run_straight
and Output State torider_detached
.
-
The video below shows the rider agents detaching from their parents after 50 frames and continuing to play their animation clip:
See also |