GKCompositeBehavior
A set of behaviors, each of which is a set of goals, that together influence the movement of an agent.
Declaration
class GKCompositeBehaviorOverview
By composing GKGoal objects into subgroups (GKBehavior objects) and composing those behaviors into composite behaviors, you can control certain aspects of a GKAgent object’s movement in concert. To assign a behavior to an agent, use its behavior property.
For example, you might create a behavior for a set of agents to stay together as a flock (with cohesion, alignment, and separation goals) while loosely following a path. With a single GKBehavior object, whenever you want to change the importance of the flocking goals relative to the path-following goals, you’d need to individually change the weight of each goal. With a composite behavior, you can adjust the relative influence of a group of goals together, as in the following code.
After constructing this behavior, you can use the setWeight(_:for:) method to increase or decrease the influence of the flock and meanderOnPath behaviors relative to one another.
To learn more about using goals and agents, see Agents, Goals, and Behaviors in GameplayKit Programming Guide.