init(toFleeAgent:)
Creates a goal whose effect is to move an agent away from the current position of the specified other agent.
Declaration
convenience init(toFleeAgent agent: GKAgent)Parameters
- agent:
An agent whose position affected agents will attempt to move away from.
Return Value
A new goal object.
Discussion
This goal is similar to one produced by the init(toAvoid:maxPredictionTime:) method with a single agent and a maxPredictionTime parameter of zero. Affected agents will attempt to move away from 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 away from 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.