<!--
{
  "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/setParent(_:preservingWorldTransform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation12HasHierarchyPAAE9setParent_24preservingWorldTransformyAA6EntityCSg_SbtF"
  },
  "title" : "setParent(_:preservingWorldTransform:)"
}
-->

# setParent(_:preservingWorldTransform:)

Attaches the entity as a child to the specified entity.

```
@MainActor @preconcurrency func setParent(_ parent: Entity?, preservingWorldTransform: Bool = false)
```

## Parameters

`parent`

The new parent entity. Use `nil` to detach the entity from its
current parent.

`preservingWorldTransform`

A Boolean that you set to `true` to preserve
the entity’s world transform, or `false` to preserve its relative
transform. Use `true` when you want a model to keep its effective
location and size within a scene.

## Discussion

Attaching an entity to a new parent automatically detaches it from its
old parent.

The [`children`](/documentation/RealityKit/HasHierarchy/children) collections of both the old and new parent
are automatically updated as well.

> Important: On visionOS, only use `preservingWorldTransform` when
> moving an entity within the same `AnchorEntity`, `ImmersiveSpace` or
> SwiftUI `WindowGroup` hierarchy. Moving entities across these
> hierarchy boundaries while `preservingWorldTransform` is set to
> `true`, is not supported.

---

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)