Class

AnimationResource

An animation that can be played by an entity.

Declaration

class AnimationResource

Overview

You find animation resources in an entity’s availableAnimations array. Animation resources come bundled with an entity when you load the entity from a file. They describe an animation that’s specific to the entity to which they are attached. Use the entity’s playAnimation(_:transitionDuration:startsPaused:) method to play a particular item in its animation resource array, or the playAnimation(named:transitionDuration:startsPaused:) method to play all of the animations with a given name. From both methods, you receive an AnimationPlaybackController instance that lets you manage playback of the resource.

If you want to loop an animation, call the resource’s repeat(count:) method to create a new resource that plays a given number of times in a row, or call the repeat(duration:) method to create a new resource that loops for the given duration. The latter loops indefinitely if you omit the duration parameter. You use the new animation resource that these methods return just as you would any other.

Topics

Naming an Animation Resource

let name: String?

The name of the animation resource.

Looping an Animation

func `repeat`(count: Int) -> AnimationResource

Repeats an animation the specified number of times.

func `repeat`(duration: TimeInterval) -> AnimationResource

Repeats an animation for the specified amount of time.

Relationships

Conforms To

See Also

Animation Playback

class AnimationPlaybackController

A controller that manages animation playback.

struct AnimationTimingFunction

The pacing of an animation transition.

enum AnimationEvents

Events triggered by the RealityKit animation system.