Contents

AnimationEvents

Notable milestones that the framework signals during animation playback.

Declaration

enum AnimationEvents

Overview

This enumeration defines the playback states that an animated entity can indicate to an app. To receive notification of a particular event, create a completion handler:

private func onAnimationCompleted(_ event:
    AnimationEvents.PlaybackCompleted) {
        // Define code that runs when the animation completes.
}

Then, subscribe the handler on the entity for the state of interest:

// Get an animation.
let animationName =
entity.availableAnimations.first!.name!

// Pass the animation to an entity and get a controller.
entity.playAnimation(named: animationName, transitionDuration: 0.0)

entitySubscription = view.scene.publisher(for:
    AnimationEvents.PlaybackCompleted.self, on: entity)
        .sink(receiveValue: onAnimationCompleted)

Topics

Recognizing animation events

Recognizing skeletal events

See Also

Physics and motion events