Справка Houdini на русском Crowd simulations

Crowd state triggers and transitions

How to specify conditions that cause agents to change from one state to another.

On this page

Overview

At each step in the simulation, Houdini looks at each agent and checks a series of trigger nodes (for example "distance to target > 2"). A logic node is available to combine triggers. If a trigger applies, Houdini checks for a transition attached to the trigger to change the agent to a new state (for example, "walk" → "run"). Transitions can have a duration during which Houdini will automatically blend the animation clips of the old and new states.

Adding a transition

Transitions control when an agent changes from one state (for example, walk) to another (for example, idle). A transition requires three decisions:

  • The state you want agents to transition out of.

  • The condition which should trigger the transition.

  • The state you want agents to transition into.

  1. Go to the crowd simulation network.

  2. Create a Crowd Trigger node. In the parameter editor, set up the trigger condition (see "built-in trigger types" below).

    You can combine multiple triggers with "And", "Or", or "Not" logic using a Crowd Trigger Logic node.

  3. Create a Crowd Transition node and wire trigger node into it.

  4. In the parameter editor for the transition node, set the Start state and End state.

  5. Wire the output of the transition node into the transition_merge node (see the crowd DOP network).

Built-in trigger types

The Crowd Trigger node includes many useful test types, as well as a Custom option that lets you write a test expression in VEX.

Trigger type

What it does

Example

Object bounds

Activates when the agent enters, leaves, or is inside some geometry.

Agents stop running when they cross the finish line of a race.

Object attribute

Activates based on the value of an attribute on some object near the agent.

Agents stop when they're at a red light, and walk when they're at a green light (use a "stop" attribute on the light object and have agents check if "stop" is 1).

Object distance

Activates based on how near to or far from an object (or point in a point cloud) the agent is.

Agents stop and turn around if they get too far from a base.

Object ray cast

Activates if an object is directly in front of an agent within a certain distance.

If an agent sees a painting, they stop to admire it.

Particle speed

Activates based on the agent’s speed.

Switch from a "walk" to a "run" to a "sprint" state/animation based on the agent’s speed.

Particle proximity

Activates based on the proximity of other agents.

Agents from different groups switch to a "fight" state when they get close together.

Particle attribute lookup

Activates based on the on the value of one of the agent’s attributes

Switch to a "dying" state if an agent’s "health" attribute gets too low.

Particle attribute comparison

Activates based on comparing the value of one of the agent’s attributes to the value of the same attribute on agents nearby

Agents run away from bigger opponents.

Time

Activates based on the scene time (for example, if the current time step is more than 5 seconds into the scene)

Agents start running halfway through the scene.

Current state duration

Activates based on how long the agent has been in its current state

Guards leave the "alert" state after 30 seconds.

Animated parameter

Activates based on a parameter on the trigger node. You can keyframe the value of the parameter for manual control, or enter an expression to activate based on a function

Agents react to hand-animated events in the rest of the scene.

Custom VEXpression

Activates based on the value of a variable after running a VEX snippet. The trigger activates if the i@trigger variable is 1 at the end of the snippet

Use this for more complex or custom requirements.

Combining triggers

The Crowd Trigger Logic node lets you combine the results of two triggers using "and", "or", or "not" relations.

Tips

  • See agent attributes for useful attributes to use in custom triggers.

  • If multiple triggers/transitions activate for a given agent, which transition is chosen is technically undefined (but it’s probably the last transition in wiring order). However, it’s best to avoid this situation by not creating multiple trigger/transition paths with the same "from" state.

See also

Crowd simulations

Getting started

The moving parts

  • Agents

    About agents, the moving "actors" that make up a crowd simulation.

  • States

    About agent states, the virtual "mood" of each agent which controls the agent’s animation and which behaviors it runs.

  • Clips

    How to associate animation with agents in certain states.

  • Triggers

    How to specify conditions that cause agents to change from one state to another.

Next steps

  • Foot planting

    How to set up agents to adapt their animation to terrain and prevent skating.

  • Transition graphs

  • Attributes

    Useful attributes for reading in triggers, or that you can set to affect behavior.

  • Sensors

    How to make agents behave differently based on their virtual senses.

  • Diversity

    How to create a more realistic crowd by making agents look and act differently.

  • Weights

    How the Houdini crowd solver decides which behaviors to apply to an agent at each time step.

  • Terrain

    How to specify terrain geometry for agents to walk across.

  • Obstacles

    How to set up obstacles for agents to avoid.

  • Dynamics interaction

    Tips on setting up interaction between agents and other types of dynamics.

  • Ragdoll simulation

  • Adding direction

    How to assert manual control over different aspects of the crowd simulation.

  • Fuzzy Logic

  • Caches

    Tips for efficiently caching and loading crowd sims.