<!--
{
  "availability" : [
    "iOS: 8.0.0 - 26.0.0",
    "iPadOS: 8.0.0 - 26.0.0",
    "macCatalyst: 13.1.0 - 26.0.0",
    "macOS: 10.8.0 - 26.0.0",
    "tvOS: 9.0.0 - 26.0.0",
    "visionOS: 1.0.0 - 26.0.0",
    "watchOS: 3.0.0 - 26.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SceneKit",
  "identifier" : "/documentation/SceneKit/SCNAnimatable/addAnimation(_:forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SceneKit"
    ],
    "preciseIdentifier" : "c:objc(pl)SCNAnimatable(im)addAnimation:forKey:"
  },
  "title" : "addAnimation(_:forKey:)"
}
-->

# addAnimation(_:forKey:)

Adds an animation object for the specified key.

```
func addAnimation(_ animation: any SCNAnimationProtocol, forKey key: String?)
```

## Parameters

`animation`

The animation object to be added.

`key`

An string identifying the animation for later retrieval. You may pass `nil` if you don’t need to reference the animation later.

## Discussion

Newly added animations begin executing after the current run loop cycle ends.

SceneKit does not define any requirements for the contents of the `key` parameter—it need only be unique among the keys for other animations you add. If you add an animation with an existing key, this method overwrites the existing animation.

---

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)