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

# setTransformMatrix(_:relativeTo:)

Sets the transform of the entity relative to the given reference entity
using a 4x4 matrix representation.

```
@MainActor @preconcurrency func setTransformMatrix(_ transform: float4x4, relativeTo referenceEntity: Entity?)
```

## Parameters

`transform`

A 4x4 transform matrix, given relative to `referenceEntity`.

`referenceEntity`

The entity that defines a frame of reference. Set
this to `nil` to indicate world space.

## Discussion

The [`Transform`](/documentation/RealityKit/Transform) component can’t represent all transforms that a
general 4x4 matrix can represent. Setting a [`transform`](/documentation/RealityKit/HasTransform/transform)
using a 4x4 matrix is therefore a lossy event that might result in
certain transformations, like shear, being dropped.

---

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)