Reputation: 127
In WWDC19 talk they showed how to animate Entity and perform action on animation completion (go to minute 12 for reference) like this:
let animationController = move(to: flipUpTransform, relativeTo: parent, duration: 0.25, timingFunction: .easeInOut)
animationController.completionHandler {
// Perform some action
}
But it looks like that they removed or never added this completionHandler
. Instead they have isCompleted
boolean property.
I am new to swift so I have no idea to use this isCompleted
to perform some actions upon animation completion. How can I solve this?
Upvotes: 1
Views: 1416
Reputation: 3554
The documentation says:
Look for one of the events in AnimationEvents if you want to be alerted when certain aspects of animation occur.
So you can use Combine to get notified when the animation finishes. so
let animation = entity.move(to: targetTransform, relativeTo: nil, duration: 1)
arView.scene.publisher(for: AnimationEvents.PlaybackCompleted.self)
.filter { $0.playbackController == animation }
.sink(receiveValue: { event in
/ * your completion handler */
}).store(in: &subscriptions)
Upvotes: 2