How to animate Entity using move(to:) with duration?

I made a scene with Reality Composer, and trying to animate my entity using move(to:relativeTo:duration:timingFunction:)

When I call move(to:) the entity moves instantly not observing the duration I specify.


Here is my code handling SceneEvent.Update and when the entity comes down below 1m, I want to rotate(roll) the entity by 30 degrees.

let updateFeed = arView.scene.subscribe(to: SceneEvents.Update.self) { event in
     if let a359 = self.sceneAnchor.findEntity(named: "A359") {
        if a359.transform.translation.y < 1 && 0.9 < a359.transform.translation.y && self.animList.count < 1 {
             // animation setup
             let rightRoll = Transform(pitch: 0, yaw: 0, roll: Float(30).radian)
             let rightRollAnimation = a359.move(to: rightRoll, relativeTo: a359, duration: 2, timingFunction: .easeOut)
             rightRollAnimation.completionHandler {
                  self.animList.removeAll()
             }
             self.animList.append(rightRollAnimation)
        }
     }
}


I change duration from 2 to 2000, but no change, moves(rotates) instantly.

Replies

Did you manage to get this to work? The entity immediatly jumps to the final transform for me, no matter how long the duration.

This has been fixed in the most recent beta! Your code had nothing wrong with it.

However you can no longer use the completionHandler in the same way; instead you'll need to use AnimationEvents:

https://developer.apple.com/documentation/realitykit/animationevents