<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKCompositeBehavior/init(behaviors:andWeights:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKCompositeBehavior(cm)behaviorWithBehaviors:andWeights:"
  },
  "title" : "init(behaviors:andWeights:)"
}
-->

# init(behaviors:andWeights:)

Creates a behavior with the specified behaviors and weights.

```
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

A new behavior object. To assign a behavior to an agent, use the agent’s [`behavior`](/documentation/GameplayKit/GKAgent/behavior) property.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)