Go To

A Go To Behavior (beGoto) finds a path to reach a target for an Entity.

To use a Go To Behavior, the Terrain Locator associated to the Crowd Manager must use a NavMesh.

A Go To behavior in the behavior editor

This behavior needs to run in parallel with a Navigation Behavior to allow Entities to avoid obstacles and other entities. See how to properly handle dual Behaviors here.

Unlike the other behaviors, the Go To Behavior automatically stops when an Entity reaches its target. If its Stop Trigger triggers before, it will stop according to this trigger.

CREATION

  • Behavior Editor / Behavior Library: 
  • Golaem Menu: Crowd Behaviors / Behaviors / CrowdBeGoto Node
  • MEL command: glmCrowdBeGotoCmd;

CONFIGURATION

A Go To Behavior defines the following specific attributes. For common attributes see Behavior Common Attributes.
 
The Go To Behavior relies on the Entity bounding cylinder, its Radius and Height parameters are set in the EntityType.

Target Attributes

Reach Mode

Two Reach Modes are available:

  • Reach: the Crowd Entities will reach their target based on the Target Mode and the Target Reach Threshold
  • Flee: the Crowd Entities will flee in the opposite direction of their target based on the Target Mode, the Target Reach Threshold and the Target Flee Threshold


Example of Reach Mode - Example of Flee Mode

Target Mode
It is possible to define a target to reach for each entity. The Target Mode attribute determines how targets are assigned:
 

Target modes of a Go To Behavior
 
A target is considered valid if its projected position on the Terrain is inside the environment and not in an obstacle zone. A target is accessible if there is a valid path from the entity's initial position to the target projected position on the navigation mesh. Figure below illustrates those differences:
 

Valid/Invalid, accessible/inaccessible targets

Random Target in Environment

If this mode is selected, each Entity will be assigned to a random valid & accessible target on the NavMesh. The targets can neither be viewed nor edited. This attribute is influenced by the random seed of the Crowd Manager.
 

Random target mode

Use Target Poptool

If this mode is selected, all entities will try to reach slots on the Crowd Target Locator selected in the "In Target Poptool" field. Here are the results of this mode:
 

Use Target Poptool

Target Particle System

If this mode is selected, each Entity will be assigned to its corresponding particle in the target particle system selected in the "In Particle System" field (i.e. entity of particleId 1 will be assigned to the target of particleId 1…). If the target particle system contains fewer particles than the navigating Entity, the entity particleId will be moduled by the size of the target particle system (i.e. entity of particle 6 will be assigned to the target of particleId 1 if the target particle system has 5 particles...).
Note that Golaem Crowd Population Tool can be used to emit the target particle system.
 

Example of a target particle system
 
It is also possible to specify the assignment of each Entity in the targeted particle system thanks to the field "Target Id PPName". If this field is set, each Entity will be assigned to the target whose id is stored in the float per-particle attribute stored in the "Target Id PPName" attribute of its relative particle. If this field is not set, or its value for one Entity is negative, the particleId will be used. See ppAttributes Handling.

Per Particle Target Attribute

If this mode is selected, each Entity will be assigned to the position stored in the vector per-particle attribute stored in the "Target PPName" attribute. The Y value of this per-particle attribute will be projected on the terrain. See ppAttributes Handling.

Example of the per-particle attribute targets

Target Expression

If this mode is selected, each entity will have a target given by the expression in the In Target Expression attribute.

Target Reach Threshold When the distance to the target is smaller than this threshold, the target is considered reached and the Go To Behavior stops. Note that if the target is another Entity, this distance should be greater than twice the Entity radius
Target Flee Threshold If the Reach Mode is set to "Flee", the target is considered reached and the Go To Behavior stops when the distance to the target is higher than this threshold.

In Vector Field Locator Paintable Vector Field locator which will influence the way the Entities will reach their target.
In Target Poptool See "Use Target Poptool" mode above.
Slot Assign Mode

Available in "Use Target Poptool" mode. This determines the way the population tool slots are assigned as goto targets

  • By Id: the population tool slots are assigned according to the entity id
  • Random: the population tool slots are assigned randomly. A random slot of the poptool will be chosen as target each time the behavior is restarted or if "Target is Dynamic" is checked.
  • MEL Command: the user can control how the slots are assigned through a MEL function specified by the "Slot Assign MEL" attribute. The MEL function uses the index of the entity. Here's a template for this function (equivalent to the "By Id" mode):
global proc int defaultSlotAssign(int $index)
{
    return $index;
}
Slot Assign MEL See "Slot Assign Mode" above
In Particle System See "Target Particle System" mode above.
Target Id PPName See "Target Particle System" mode above.
Target PPName See "Per Particle Target Attribute" mode above.
Target is Dynamic 

The Target Is Dynamic checkbox must be checked for a moving target. When enabling this option, the Target Update Period becomes available. When using dynamic targets, the path of the Entity to the target will be recomputed during the simulation.

When using dynamic targets, it is possible to make two particle systems target each other (i.e. for battle scenes).

Target Update Period This parameter defines the number of frames before recomputing the path to the target (which means that during this time, the target's position won't change). Keep in mind that computing the path to the target is a heavy operation that can decrease the performance of the crowd simulation, especially if the target update period is low.