<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/HasHierarchy",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation12HasHierarchyP"
  },
  "title" : "HasHierarchy"
}
-->

# HasHierarchy

An interface that provides access to a parent entity and child entities.

```
@MainActor @preconcurrency protocol HasHierarchy : Entity
```

## Overview

All entities automatically adopt this protocol because the [`Entity`](/documentation/RealityKit/Entity) base
class does. This adoption gives all entities a collection of methods for
managing the hierarchy.

## Topics

### Managing the parent

[`var parent: Entity?`](/documentation/RealityKit/HasHierarchy/parent)

The parent entity.

[`func setParent(Entity?, preservingWorldTransform: Bool)`](/documentation/RealityKit/HasHierarchy/setParent(_:preservingWorldTransform:))

Attaches the entity as a child to the specified entity.

[`func removeFromParent(preservingWorldTransform: Bool)`](/documentation/RealityKit/HasHierarchy/removeFromParent(preservingWorldTransform:))

Removes the entity from its current parent or from the scene if it is a
root entity.

### Managing children

[`var children: Entity.ChildCollection`](/documentation/RealityKit/HasHierarchy/children)

The child entities that the entity manages.

[`func addChild(Entity, preservingWorldTransform: Bool)`](/documentation/RealityKit/HasHierarchy/addChild(_:preservingWorldTransform:))

Adds the given entity to the collection of child entities.

[`func removeChild(Entity, preservingWorldTransform: Bool)`](/documentation/RealityKit/HasHierarchy/removeChild(_:preservingWorldTransform:))

Removes the given child from the entity.

## Relationships

### Conforming Types

[`DirectionalLight`](/documentation/RealityKit/DirectionalLight)

[`PerspectiveCamera`](/documentation/RealityKit/PerspectiveCamera)

[`ModelEntity`](/documentation/RealityKit/ModelEntity)

[`PointLight`](/documentation/RealityKit/PointLight)

[`Entity`](/documentation/RealityKit/Entity)

[`SpotLight`](/documentation/RealityKit/SpotLight)

[`TriggerVolume`](/documentation/RealityKit/TriggerVolume)

[`ViewAttachmentEntity`](/documentation/RealityKit/ViewAttachmentEntity)

[`AnchorEntity`](/documentation/RealityKit/AnchorEntity)

[`BodyTrackedEntity`](/documentation/RealityKit/BodyTrackedEntity)

### Inherits From

[`Entity`](/documentation/RealityKit/Entity)

---

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)