---
title: "transformMatrix(relativeTo:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/hastransform/transformmatrix(relativeto:)"
---

# transformMatrix(relativeTo:)

Gets the 4 x 4 transform matrix of an entity relative to the given entity.

## Declaration

```swift
@MainActor @preconcurrency func transformMatrix(relativeTo referenceEntity: Entity?) -> float4x4
```

## Parameters

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

## Return Value

Return Value The transform of the entity relative to referenceEntity.

## See Also

### Using a matrix

- [Transforming entities between RealityKit coordinate spaces](realitykit/transforming-entities-between-realitykit-coordinate-spaces.md)
