<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/AnimationLibraryComponent/automaticallyPlaysDefaultAnimation",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation25AnimationLibraryComponentV025automaticallyPlaysDefaultC0Sbvp"
  },
  "title" : "automaticallyPlaysDefaultAnimation"
}
-->

# automaticallyPlaysDefaultAnimation

Whether to automatically play the default animation when the entity is added to a scene and enabled.
Default value is false, meaning the default animation will not be automatically played by default. This
value can only be set when initializing `AnimationLibraryComponent`

```
var automaticallyPlaysDefaultAnimation: Bool { get }
```

## Return Value

- `true` if automatically play default animation is enabled
- `false` if automatically play default animation is disabled

## Discussion

When set to `true`, the animation system automatically plays the default animation
when the entity is added to a scene and enabled. The animation that auto-plays is determined by
[`defaultKey`](/documentation/RealityKit/AnimationLibraryComponent/defaultKey). If `defaultKey` is set, the system plays the
animation stored under that key. If `defaultKey` is not set, the system plays the first animation in
the library. If the library contains no animations, auto-play has no effect.

This is useful for background objects with looping animations, idle character states, or any entity whose
animation should start without requiring code.

When set to `false`, animations require manual playback using
[`playAnimation(_:transitionDuration:startsPaused:)`](/documentation/RealityKit/Entity/playAnimation(_:transitionDuration:startsPaused:)). Use manual playback when
you need to control timing, pass custom parameters, or coordinate animation start with other game logic.

Disabling the entity or removing the `AnimationLibraryComponent` will stop any auto-playing animation.

## Example

```swift
var library = AnimationLibraryComponent(automaticallyPlaysDefaultAnimation: true)
library["idle"] = idleAnimation
library.defaultKey = "idle"
entity.components.set(library)
// Animation plays automatically when the entity is added to a scene and enabled
```

---

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)