---
title: "init(behaviors:andWeights:)"
framework: gameplaykit
role: symbol
role_heading: Initializer
path: "gameplaykit/gkcompositebehavior/init(behaviors:andweights:)"
---

# init(behaviors:andWeights:)

Creates a behavior with the specified behaviors and weights.

## Declaration

```swift
convenience init(behaviors: [GKBehavior], andWeights weights: [NSNumber])
```

## Parameters

- `behaviors`: An array of behavior objects.
- `weights`: An array of numbers, each of which is the weight to be applied to the behavior at the corresponding index in the behaviors array.

## Return Value

Return Value A new behavior object. To assign a behavior to an agent, use the agent’s behavior property.

## See Also

### Creating a Composite Behavior

- [init(behaviors:)](gameplaykit/gkcompositebehavior/init(behaviors:).md)
