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
Declaration
var automaticallyPlaysDefaultAnimation: Bool { get }Return Value
trueif automatically play default animation is enabledfalseif 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. 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:). 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
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