<!--
{
  "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/subscript(_:)-6krdg",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Subscript",
  "symbol" : {
    "kind" : "Instance Subscript",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKCompositeBehavior(im)objectAtIndexedSubscript:"
  },
  "title" : "subscript(_:)"
}
-->

# subscript(_:)

Returns the individual behavior at the specified index in the composite behavior’s list of behaviors.

```
subscript(idx: Int) -> GKBehavior { get }
```

## Parameters

`idx`

An index in the composite behavior’s list of individual behaviors; it must be less than the value of the [`behaviorCount`](/documentation/GameplayKit/GKCompositeBehavior/behaviorCount) property.

## Return Value

The behavior at the specified index.

## Discussion

The order of individual behaviors in a composite behavior is undefined. However, you can use this method to enumerate all individual behaviors in a composite behavior.

---

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)