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:
- The Avoid behavior is one of the most commonly used behaviors. Use this behavior to cause crowd members to avoid other crowd members, or spherical
objects in the scene. It works by creating a spherical volume of avoidance around the avoided object, so it doesn’t accommodate irregular objects.
The Avoid behavior is unlike any other behavior in Crowd. After all the other behaviors exert their forces on the delegates,
Avoid takes over and has the power to turn, slow down, and even stop a delegate in order to make it avoid an obstacle.
- Use the Wall Repel behavior to cause crowd members to avoid broad, flat objects such as walls and fences. You can set a maximum distance for the repel
effect, and describe the rate at which the force away from the wall increases as a delegate approaches the wall.
Unlike the Avoid behavior, which can stop or slow down a delegate, Wall Repel simply exerts a force on the delegate to turn
it away from the wall. It does not guarantee wall avoidance. You must work with it’s distance and falloff parameters, as well
as its weight in the Assignments and Teams dialog, to control its strength.
- Use the Repel behavior to cause crowd members to turn away from an object. It works exactly like Wall Repel except that it uses a spherical volume
rather than a plane. You can set a maximum distance for the repel effect, and describe the rate at which the repel force increases
as the delegate approaches the obstacle.
Repel exerts a force on the delegate to turn it away from the obstacle. It does not guarantee avoidance. You must work with
its Distance and Falloff parameters, as well as its weight in the Behavior Assignments and Teams dialog, to control its strength. Repel can be used instead of the Avoid behavior as a simple avoidance technique for non-terrestrial
creatures such as fish or birds.
- Use a Vector Field. This is a special type of space warp that crowd members can use to move around irregular objects such as a curved, concave
surface. You can use the Vector Field space warp in conjunction with the Avoid behavior to make delegates slow down when they
approach a complex object, and then go around it. This guarantees that the delegate will not pass through the obstacle’s surface.
You can also use the Vector Field space warp in conjunction with the Space Warp behavior. This simply exerts a force on the delegate that mimics the contours of the object. It does not assure that the delegate
will not pass through the surface of the obstacle. You can use a Vector Field with both the Space Warp and Avoid behaviors
to combine their effects.
Procedures
To use the Avoid behavior:
- Add an Avoid behavior to the Crowd object.
- In the Avoid Behavior rollout, use the None button or (Multiple Selection) to designate the target object or objects to avoid.
TipTo 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.
- Turn on Display Hard Radius to see the radial avoidance area in viewports. Adjust the Hard Radius to the appropriate size
for your delegates.
- Adjust the Brake Pressure to determine whether a delegate will slow down when it encounters an avoided object.
- Adjust the Look Ahead parameter to determine how many frames ahead each delegate will look to determine the best way to avoid
others.
- Use Behavior Assignments to assign the behavior to a delegate or team.
To use the Wall Repel behavior:
- On the Create panel, click (Helpers), then click Grid. Create a grid in the scene.
TipFor best results, do not use Mirror to copy a grid to be used with behaviors. Use Shift+Clone instead.
- Move and rotate the grid to position it.
TipThe 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.
- Select the Crowd object, and add a Wall Repel behavior.
- In the Wall Repel Behavior rollout, click None, and pick the grid.
- 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.
- 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.
- Use Behavior Assignments to assign the behavior to a delegate or team.
To use the Repel behavior:
- Add a Repel behavior to the Crowd object.
- In the Repel Behavior rollout, use the None button or (Multiple Selection) to designate the object or objects that are to repel delegates.
- Change the default settings as desired.
- 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.
- On the Object Type rollout, click Vector Field.
- 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.
- 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.
- Create an object to serve as an obstacle. This object must be an editable mesh or geometric primitive; it can have modifiers.
- Add a Vector Field space warp.
- 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.
- 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.
- 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.
- 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.
- Turn off Display group Show Lattice and Show Range so that the vector field will be more easily visible when generated.
- Turn on Display group Show Vector Field.
- In the Compute Vectors group, click the Compute button. This generates the vector field.
TipTo 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.
- Add Crowd and Delegate helper objects.
- Select the Crowd object and open the Modify panel.
- In the Setup rollout Behaviors group, click New.
- In the Select Behavior Type dialog that is displayed, choose Space Warp Behavior, and then click OK.
- 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.
TipYou might find it easier to use Select By Name to select the space warp.
- 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.
- Add any other objects or behaviors appropriate to the simulation.
- Select the Crowd object, and then solve the simulation by clicking the Solve rollout Solve button.
- Fine tune the behavior associated with the Vector Field space warp by adjusting the Lattice parameters and Obstacle parameters.
- 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.