Reaching a Target, Fleeing
Please follow previous section, Basic Workflow, to setup a basic flock first.
Adding a target to seek or flee
snapshot of what a seeking flock may looks like, target is shown by translating tool gizmo
Leading a flock to a target is easily achieved by adding a Steer Behavior.
One can achieve this by :
- creating a Population Tool Locator
- moving it to the suitable target position
- adding a Steer Behavior in parallel with Flock Behavior
- set its Steer Mode to "Reach".
- selecting the previously created poptool locator in the Steer Behavior In Target Poptool list parameter.
The Steer Behavior should looks like the following image:
Steer Behavior configured to reach a target, with constant weight
The process is identical for fleeing, except that Steer Behavior Steer Mode must be set to "Flee".
Absolute Weights
By default, the target will attract/flee boids from any distance at its maximum weight (1.0).
Weights control :
- the relative importance of each steer target, if total Steer Behavior weights are > 1
- the absolute target attraction/repulsion intensity, if total weights are < 1
To have an absolute target weight other than one, just move Weight At Max Distance value from 1.0 to less. As Max distance is 0, this value will be used for all boids (see below).
To see how weights and forces are mixed to move a boid, see Steer Behavior reference guide.
Target Area of effect
Min/Max Distance and weights of Steer Behavior allow to define several distance intervals :
- from 0 to Min Distance, weight of the target will be interpolated from 0 to Weight At Min Distance
- from Min Distance to Max Distance, weight of the target will be interpolated from Weight At Min Distance to Weight At Max Distance
- above Max Distance, Weight At Max Distance will be used.
Considering this
- target effect can be limited to a given distance by zeroing Weight At Max Distance and choosing Min/Max Distance appropriately
- target effect can be decreased around target, by setting Min Distance to a non null value. This avoids the crowding effect around the target in seek mode.
Here is a quick overview of weights impact :
Default SteerBehavior parameters
Same frame, with Steer Behavior Min Distance set to 40.
We can improve the natural effect by also increasing the separation of flock, in the Flock Locator. Let's set separation weight to 20 instead of its default 12 value :
Same frame, with a Min Distance of 40 and a Flock Locator separation weight of 20