---
title: GKBehavior
framework: gameplaykit
role: symbol
role_heading: Class
path: gameplaykit/gkbehavior
---

# GKBehavior

A set of goals that together influence the movement of an agent.

## Declaration

```swift
class GKBehavior
```

## Overview

Overview By combining multiple goals (GKGoal objects) you can create complex behavior, such as groups of agents  (GKAgent objects) that move together naturally. To assign a set of goals to an agent, use its behavior property. To learn more about using goals and agents, see Agents, Goals, and Behaviors in GameplayKit Programming Guide.

## Topics

### Creating a Behavior

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

### Managing a Behavior’s Set of Goals

- [setWeight(_:for:)](gameplaykit/gkbehavior/setweight(_:for:).md)
- [weight(for:)](gameplaykit/gkbehavior/weight(for:).md)
- [remove(_:)](gameplaykit/gkbehavior/remove(_:).md)
- [removeAllGoals()](gameplaykit/gkbehavior/removeallgoals().md)
- [goalCount](gameplaykit/gkbehavior/goalcount.md)

### Working with Goals Using Subscript Syntax

- [subscript(_:)](gameplaykit/gkbehavior/subscript(_:)-2yvko.md)
- [subscript(_:)](gameplaykit/gkbehavior/subscript(_:)-997a9.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [GKCompositeBehavior](gameplaykit/gkcompositebehavior.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCopying](foundation/nscopying.md)
- [NSFastEnumeration](foundation/nsfastenumeration.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Agents, Goals, and Behaviors

- [GKAgent](gameplaykit/gkagent.md)
- [GKAgent2D](gameplaykit/gkagent2d.md)
- [GKAgent3D](gameplaykit/gkagent3d.md)
- [GKGoal](gameplaykit/gkgoal.md)
- [GKCompositeBehavior](gameplaykit/gkcompositebehavior.md)
- [GKPath](gameplaykit/gkpath.md)
- [GKAgentDelegate](gameplaykit/gkagentdelegate.md)
