---
title: "weight(for:)"
framework: gameplaykit
role: symbol
role_heading: Instance Method
path: "gameplaykit/gkbehavior/weight(for:)"
---

# weight(for:)

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

## Declaration

```swift
func weight(for goal: GKGoal) -> Float
```

## Parameters

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

## Return Value

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

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

### Related Documentation

- [subscript(_:)](gameplaykit/gkbehavior/subscript(_:)-2yvko.md)

### Managing a Behavior’s Set of Goals

- [setWeight(_:for:)](gameplaykit/gkbehavior/setweight(_:for:).md)
- [remove(_:)](gameplaykit/gkbehavior/remove(_:).md)
- [removeAllGoals()](gameplaykit/gkbehavior/removeallgoals().md)
- [goalCount](gameplaykit/gkbehavior/goalcount.md)
