Instance Method

weightForGoal:

Returns the weight for the specified goal’s influence on agents.

Declaration

- (float)weightForGoal:(GKGoal *)goal;

Parameters

goal

A goal already included in the behavior’s set of goals.

Return Value

The weight to be applied to the goal’s influence on an agent’s speed and direction, or 0.0 if the goal is not in the behavior.

Discussion

When an agent evaluates its behavior, it examines each goal and calculates the change in direction and speed necessary to move toward fulfilling that goal (within the limits of the current time step and the agent’s maximum speed and turn rate). The agent then combines these influences to determine the total change in direction and speed for the current time step. Weights modulate the effects of multiple goals in a behavior.

See Also

Managing a Behavior’s Set of Goals

- setWeight:forGoal:

Sets the weight for the specified goal’s influence on agents, adding that goal to the behavior if not already present.

- removeGoal:

Removes the specified goal from the behavior.

- removeAllGoals

Removes all goals from the behavior.

goalCount

The number of goals in the behavior.