<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/Entity/transformMatrix(relativeTo:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation6EntityC15transformMatrix10relativeToSo13simd_float4x4aSgAC24CoordinateSpaceReferenceO_tF"
  },
  "title" : "transformMatrix(relativeTo:)"
}
-->

# transformMatrix(relativeTo:)

Returns the 4 x 4 transform matrix of an entity relative to the given
coordinate space.

```
@MainActor @preconcurrency func transformMatrix(relativeTo referenceSpace: Entity.CoordinateSpaceReference) -> float4x4?
```

## Parameters

`referenceSpace`

The coordinate space that defines a frame of reference.

## Return Value

The transform of the entity relative to `referenceSpace`, or `nil` when the given coordinate space is not applicable to the given entity.

## Discussion

This method overloads  [`transformMatrix(relativeTo:)`](/documentation/RealityKit/HasTransform/transformMatrix(relativeTo:)).

---

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)