<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation25AnimationLibraryComponentV0C10CollectionV"
  },
  "title" : "AnimationLibraryComponent.AnimationCollection"
}
-->

# AnimationLibraryComponent.AnimationCollection

A collection of animations an entity can play.

```
struct AnimationCollection
```

## Overview

You use `AnimationCollection` to access animations in an
[`AnimationLibraryComponent`](/documentation/RealityKit/AnimationLibraryComponent).

The initializers for [`AnimationLibraryComponent`](/documentation/RealityKit/AnimationLibraryComponent) create an `AnimationCollection`,
so you don’t need to create one directly. You can access the collection with the
[`animations`](/documentation/RealityKit/AnimationLibraryComponent/animations) property.

## Topics

### Creating an animation collection

[`init(dictionaryLiteral: (String, AnimationResource)...)`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/init(dictionaryLiteral:))

Creates an animation collection from a dictionary literal.

### Inspecting an animation collection

### Accessing animations

[`subscript(String) -> AnimationResource?`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/subscript(_:)-4sfyo)

Accesses a single animation in the collection with a key.

[`subscript(Range<AnimationLibraryComponent.AnimationCollection.Index>) -> AnimationLibraryComponent.AnimationCollection.SubSequence`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/subscript(_:)-2n5pw)

Accesses animations in the collection within an index range.

[`subscript(AnimationLibraryComponent.AnimationCollection.Index) -> AnimationLibraryComponent.AnimationCollection.Element`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/subscript(_:)-45p83)

Accesses a single animation in the collection at an index.

[`typealias SubSequence`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/SubSequence)

A sequence that represents a contiguous subrange of animations in the collection.

[`typealias Element`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/Element)

A key-value pair from the collection consisting of the name of an animation and the animation itself.

### Manipulating indices

[`var startIndex: AnimationLibraryComponent.AnimationCollection.Index`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/startIndex)

An index to the first animation in the collection.

[`var endIndex: AnimationLibraryComponent.AnimationCollection.Index`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/endIndex)

An index to the last animation in the collection.

[`func index(after: AnimationLibraryComponent.AnimationCollection.Index) -> AnimationLibraryComponent.AnimationCollection.Index`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/index(after:))

Returns the position in the collection that follows an index.

[`func formIndex(after: inout AnimationLibraryComponent.AnimationCollection.Index)`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/formIndex(after:))

Replaces the index with its successor.

[`struct Index`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/Index)

An object that represents a position in the collection.

### Iterating over animations

[`func makeIterator() -> AnimationLibraryComponent.AnimationCollection.Iterator`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/makeIterator())

Returns an iterator over the animations in the collection.

[`struct Iterator`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/Iterator)

An object to iterate over all animations in the collection.

### Instance Properties

[`var count: Int`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/count)

The number of animations in the collection.

[`var isEmpty: Bool`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/isEmpty)

A Boolean value that indicates whether the collection is empty.

### Subscripts

[`subscript(_:)`](/documentation/RealityKit/AnimationLibraryComponent/AnimationCollection/subscript(_:))

Accesses animations in the collection within an index range.

## Relationships

### Conforms To

[`Collection`](/documentation/Swift/Collection)

[`Sequence`](/documentation/Swift/Sequence)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)