Initializer

init(toSeekAgent:)

Creates a goal whose effect is to move an agent toward the current position of the specified other agent.

Declaration

convenience init(toSeekAgent agent: GKAgent)

Parameters

agent

An agent whose position affected agents will attempt to move toward.

Return Value

A new goal object.

Discussion

This goal is similar to one produced by the init(toInterceptAgent:maxPredictionTime:) method with a maxPredictionTime parameter of zero. Affected agents will attempt to move toward the target agent, but without taking the target’s movement into account.

You can also use this goal when you want an agent to move toward a target point, such as the current mouse or touch location. Create another agent that remains stationary at the target point (that is, has no velocity and no goals), and use that agent as the parameter when creating a goal with this method.

See Also

Creating Goals for General Movement Behavior

init(toFleeAgent: GKAgent)

Creates a goal whose effect is to move an agent away from the current position of the specified other agent.

init(toReachTargetSpeed: Float)

Creates a goal whose effect is to accelerate or decelerate an agent until it reaches the specified speed.

init(toWander: Float)

Creates a goal whose effect is to make an agent wander aimlessly, moving forward and turning at random.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software