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

# init(goals:andWeights:)

Creates a behavior with the specified goals and weights.

```
convenience init(goals: [GKGoal], andWeights weights: [NSNumber])
```

## Parameters

`goals`

An array of goal objects.

`weights`

An array of numbers, each the weight to be applied to the goal at the corresponding index in the `goals` array.

## Return Value

A new behavior object. To assign a set of goals to an agent, use its [`behavior`](/documentation/GameplayKit/GKAgent/behavior) property.

---

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)