<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/BehaviorTreeComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation21BehaviorTreeComponentV"
  },
  "title" : "BehaviorTreeComponent"
}
-->

# BehaviorTreeComponent

Manages which behavior tree is active for the component’s entity.

```
struct BehaviorTreeComponent
```

## Topics

### Creating a behavior tree component

[`init(behaviorTree:availableBehaviorTrees:)`](/documentation/RealityKit/BehaviorTreeComponent/init(behaviorTree:availableBehaviorTrees:))

### Accessing behavior trees

[`behaviorTree`](/documentation/RealityKit/BehaviorTreeComponent/behaviorTree)

Accesses the current behavior tree. Note that setting the behavior tree to a tree not in
`availableBehaviorTrees` will add a uniquely-named entry for the tree in `availableBehaviorTrees`.

[`availableBehaviorTrees`](/documentation/RealityKit/BehaviorTreeComponent/availableBehaviorTrees)

All the behavior trees that this component can access.



---

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)