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

# init(goals:andWeights:)

Creates a behavior with the specified goals and weights.

## Declaration

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

Return Value A new behavior object. To assign a set of goals to an agent, use its behavior property.

## See Also

### Creating a Behavior

- [init(goal:weight:)](gameplaykit/gkbehavior/init(goal:weight:).md)
- [init(goals:)](gameplaykit/gkbehavior/init(goals:).md)
- [init(weightedGoals:)](gameplaykit/gkbehavior/init(weightedgoals:).md)
