Obstacle Avoidance

An important part of crowd behavior is avoidance of obstacles. Think of an obstacle as anything that impedes a crowd member's progress. Examples of obstacles include walls, telephone poles, and fences, as well as other crowd members. Encountering such objects can cause avoidance behavior, which consists of any combination of slowing down, turning, and stopping.

There are several ways to implement avoidance in character studio, including:

Procedures

To use the Avoid behavior:

  1. Add an Avoid behavior to the Crowd object.
  2. In the Avoid Behavior rollout, use the None button or (Multiple Selection) to designate the target object or objects to avoid.
    Tip: To make an entire team of delegates avoid each other, choose all delegates in the team. The crowd system will cause each delegate to avoid all others except itself.
  3. Turn on Display Hard Radius to see the radial avoidance area in viewports. Adjust the Hard Radius to the appropriate size for your delegates.
  4. Adjust the Brake Pressure to determine whether a delegate will slow down when it encounters an avoided object.
  5. Adjust the Look Ahead parameter to determine how many frames ahead each delegate will look to determine the best way to avoid others.
  6. Use Behavior Assignments to assign the behavior to a delegate or team.

To use the Wall Repel behavior:

  1. On the Create panel, click (Helpers), then click Grid. Create a grid in the scene.
    Tip: For best results, do not use Mirror to copy a grid to be used with behaviors. Use Shift+Clone instead.
  2. Move and rotate the grid to position it.
    Tip: The Wall Repel behavior repels delegates from the grid in the direction of grid's local Z axis. With the grid still selected, use the Local coordinate system to see the direction of the Z axis in viewports; the axis arrow points in the direction of the positive Z axis. Checking the Z-axis direction will speed the process of setting up the behavior.
  3. Select the Crowd object, and add a Wall Repel behavior.
  4. In the Wall Repel Behavior rollout, click None, and pick the grid.
  5. Choose Positive Axis to cause the delegates to be repelled from the Z-axis side of the grid. You can also choose Negative Axis to repel delegates from the opposite side of the grid, or Both to repel them from both sides.
  6. If you want delegates to be attracted to the grid only when they are within a specified area in front of the grid (rather than when they are anywhere in the scene), turn on Use Distance. Use the Inner Distance and Outer Distance parameters to set the area in which delegates will be attracted to the grid. Turn on Display Distance to see the distance in viewports.
  7. Use Behavior Assignments to assign the behavior to a delegate or team.

To use the Repel behavior:

  1. Add a Repel behavior to the Crowd object.
  2. In the Repel Behavior rollout, use the None button or (Multiple Selection) to designate the object or objects that are to repel delegates.
  3. Change the default settings as desired.
  4. Use Behavior Assignments to assign the behavior to a delegate or team.

To add a Vector Field space warp:

    Adding a Vector Field space warp object works the same as adding a Box geometry primitive.

  1. On the Object Type rollout, click Vector Field.
  2. Drag in a viewport to set the initial dimensions.
    • If using the Cube creation method, this sets all three dimensions simultaneously.
    • If using the Box creation method, release the mouse button, and then move the mouse vertically to set the height.
  3. Click to create the space warp.

To use a Vector Field space warp with delegates:

    This procedure presents general guidelines for using the Vector Field space warp with delegates in a crowd simulation.

  1. Create an object to serve as an obstacle. This object must be an editable mesh or geometric primitive; it can have modifiers.
  2. Add a Vector Field space warp.
  3. Position and scale the space warp lattice so that it encloses the obstacle object.

    The lattice should be significantly larger than the object. The object should be located roughly at the lattice center.

  4. In the Lattice Parameters rollout, increase the Length Segs/Width Segs/Height Segs settings so that the lattice segments intersect the object at reasonable intervals.

    To determine appropriate Segs settings for your obstacle objects, first examine the object complexity. If the obstacle has a lot of detail, and you want that detail reflected in the vector field, then you need a relatively high lattice resolution.

  5. Click the Obstacle Parameters rollout Compute Vectors group Vector Field Object button (initially labeled None), and then in a viewport, click the object that will act as an obstacle in the crowd simulation.

    This specifies the obstacle object. The range volume grid appears on the object's surface as an olive-colored wireframe.

  6. Increase the Obstacle Parameters rollout Compute Vectors group Range setting.

    As you increase this setting, you'll see the range volume grid expand. The range volume should enclose the space in which crowd members need to start turning in order to avoid the object.

  7. Turn off Display group Show Lattice and Show Range so that the vector field will be more easily visible when generated.
  8. Turn on Display group Show Vector Field.
  9. In the Compute Vectors group, click the Compute button. This generates the vector field.
    Tip: To make the vector lines more evident, increase the Display group VectorScale setting.

    The vectors appear as blue lines surrounding the obstacle object. One vector is computed for each lattice intersection within the range volume grid. Each vector matches the normal of the object at the point on the object's surface closest to the lattice point.

    The vector force falls off with distance from the object, as shown by the progressively shorter vector lines toward the grid perimeter.

  10. Add Crowd and Delegate helper objects.
  11. Select the Crowd object and open the Modify panel.
  12. In the Setup rollout Behaviors group, click New.
  13. In the Select Behavior Type dialog that is displayed, choose Space Warp Behavior, and then click OK.
  14. In the Space Warp Behavior rollout that appears, click the button (initially labeled “None”), and then in a viewport, click the Vector Field space warp.
    Tip: You might find it easier to use Select By Name to select the space warp.
  15. In the Setup rollout, click the Behavior Assignments button, and use the Behavior Assignments And Teams dialog to assign your delegate or delegates to the space warp behavior.
  16. Add any other objects or behaviors appropriate to the simulation.
  17. Select the Crowd object, and then solve the simulation by clicking the Solve rollout Solve button.
  18. Fine tune the behavior associated with the Vector Field space warp by adjusting the Lattice parameters and Obstacle parameters.
  19. Continue computing the vector field and then solving the simulation after each adjustment. In certain cases you might need to animate the vector field parameters to keep objects within the field.