---
title: "move(to:relativeTo:duration:timingFunction:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/hastransform/move(to:relativeto:duration:timingfunction:)-35qp2"
---

# move(to:relativeTo:duration:timingFunction:)

Moves an entity over a period of time to a new location given by a transform.

## Declaration

```swift
@discardableResult @MainActor @preconcurrency func move(to target: Transform, relativeTo referenceEntity: Entity?, duration: TimeInterval, timingFunction: AnimationTimingFunction = .default) -> AnimationPlaybackController
```

## Parameters

- `target`: A doc://com.apple.RealityKit/documentation/RealityKit/Transform instance that indicates the new location.
- `referenceEntity`: The entity that defines a frame of reference. Set this to nil to indicate world space.
- `duration`: The time in seconds over which the move should occur.
- `timingFunction`: A timing function that controls the progress of the animation.

## Return Value

Return Value An AnimationPlaybackController instance that you use to control the animation playback.

## Discussion

Discussion Animating the scale of an entity to 0 will cause a subsequent inverse of the entity’s transform to return NaN values.  Developers may consider animating the scale of an entity to a small non-zero value. When the move completes, the entity can then be hidden or removed if applicable to the use case.

## See Also

### Animating an entity

- [move(to:relativeTo:duration:timingFunction:)](realitykit/hastransform/move(to:relativeto:duration:timingfunction:)-6la93.md)
