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

# weight(for:)

Returns the weight for the specified individual behavior’s influence on agents.

## Declaration

```swift
func weight(for behavior: GKBehavior) -> Float
```

## Parameters

- `behavior`: An individual behavior already included in the composite behavior.

## Return Value

Return Value The weight applied to that behavior’s influence on an agent’s speed and direction, or 0.0 if that behavior is not in the composite behavior.

## Discussion

Discussion When an agent evaluates a composite behavior, it examines all goals across all of the individual behaviors it contains. For each goal, the agent 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. Individual goals, or individual behaviors that group goals in a composite behavior, have more influence on an agent when given a greater weight.

## See Also

### Related Documentation

- [subscript(_:)](gameplaykit/gkcompositebehavior/subscript(_:)-6jng9.md)
- [subscript(_:)](gameplaykit/gkcompositebehavior/subscript(_:)-6krdg.md)

### Managing the Individual Behaviors in a Composite Behavior

- [setWeight(_:for:)](gameplaykit/gkcompositebehavior/setweight(_:for:).md)
- [remove(_:)](gameplaykit/gkcompositebehavior/remove(_:).md)
- [removeAllBehaviors()](gameplaykit/gkcompositebehavior/removeallbehaviors().md)
- [behaviorCount](gameplaykit/gkcompositebehavior/behaviorcount.md)
