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

# transformMatrix(relativeTo:)

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

## Declaration

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

## Parameters

- `referenceSpace`: The coordinate space that defines a frame of reference.

## Return Value

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

Discussion This method overloads  transformMatrix(relativeTo:).

## See Also

### Positioning entities in space

- [HasTransform](realitykit/hastransform.md)
- [Transform](realitykit/transform.md)
- [Entity.CoordinateSpaceReference](realitykit/entity/coordinatespacereference.md)
- [Entity.ForwardDirection](realitykit/entity/forwarddirection.md)
