An influence that motivates the movement of one or more agents.
- iOS 9.0+
- macOS 10.11+
- tvOS 9.0+
Goals can motivate agents (
GKAgent objects) to actions such as moving toward a target, following a path, or staying aligned with a group of other agents. To give an agent one or more goals, combine those goals in a
GKBehavior object (which includes weights for the relative influence of each goal) and assign that object to the agent’s
Each time an agent’s
update(delta method runs, the agent evaluates each goal in its behavior to find the change in direction and speed necessary to move toward fulfilling that goal (within the limits of the time delta and the agent’s maximum speed and turn rate). It then combines the effects from all the goals in its behavior, using the weights in the behavior to modulate the influence of each goal, to produce a total change in its direction and speed.