A set of behaviors, each of which is a set of goals, that together influence the movement of an agent.
- iOS 10.0+
- macOS 10.12+
- Mac Catalyst 13.0+
- tvOS 10.0+
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
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
set method to increase or decrease the influence of the
meander behaviors relative to one another.