playAnimation(_:transitionDuration:blendLayerOffset:separateAnimatedValue:startsPaused:clock:)
Plays an animation with the specified options.
Declaration
@discardableResult @MainActor @preconcurrency func playAnimation(_ animation: AnimationResource, transitionDuration: TimeInterval = 0, blendLayerOffset: Int = 0, separateAnimatedValue: Bool = false, startsPaused: Bool = false, clock: CMClockOrTimebase? = nil) -> AnimationPlaybackControllerParameters
- animation:
The animation to play.
- transitionDuration:
The duration in seconds over which the animation fades in or cross-fades.
- blendLayerOffset:
An integer that specifies the order in which to apply animations when more than one animation is playing. Valid values are
0or1. - separateAnimatedValue:
When set to false, this value indicates that the animation will write directly to the entity’s base value. When set to true, this value indicates that the animation will write to an interim value for the duration of the animation. If this value is set to true then when the animation completes, the entity’s value will be reset to the base value.
- startsPaused:
A Boolean that pauses the progress of an animation when set to
true. - clock:
An optional clock to drive the animation with a custom timescale.
Discussion
Call this method to play an animation and configure playback options. RealityKit supports blending up to two different animations at the same time. When RealityKit applies multiple animations to an entity, the order in which it applies the animations affects the final animation. Use the blendLayerOffset parameter to specify the order of animations when playing multiple animations at the same time.
See Also
Animating an entity
availableAnimationsplayAnimation(_:transitionDuration:blendLayerOffset:separateAnimatedValue:startsPaused:clock:handoffType:)playAnimation(_:transitionDuration:startsPaused:)stopAllAnimations(recursive:)defaultAnimationClockparametersEntity.ParameterSetplayAnimation(named:transitionDuration:startsPaused:recursive:)bindableValuessubscript(_:)