<!--
{
  "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/SpinAction",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation10SpinActionV"
  },
  "title" : "SpinAction"
}
-->

# SpinAction

An action which animates the transform of an entity to rotate around a specified local axis.

```
struct SpinAction
```

## Overview

This action rotates an entity around itself from a specified [`localAxis`](/documentation/RealityKit/SpinAction/localAxis)
gradually adjusting its local transform.
The [`localAxis`](/documentation/RealityKit/SpinAction/localAxis) specifies which cartesian axis around which to rotate in
local space.
The full spin completes after the action has ended.

The example below creates an animation that spins an entity
around the x-axis two times for five seconds with a linear transition.

```swift
// Create an action that performs a spin around the specified local axis
// with a linear transition.
let spinAction = SpinAction(revolutions: 2,
                            localAxis: [1, 0, 0],
                            timingFunction: .linear,
                            isAdditive: false)

// A five second animation that plays an animation causing the entity to
// spin around a specified local axis.
let spinAnimation = try AnimationResource
    .makeActionAnimation(for: spinAction,
                         duration: 5.0,
                         bindTarget: .transform)

// Play the five second spin animation.
entity.playAnimation(spinAnimation)
```

> Note: Use the ``doc://com.apple.RealityKit/documentation/RealityKit/SpinAction/localAxis`` to determine whether the entity
> spins clockwise or counterclockwise.

> Important: This action directly animates the ``doc://com.apple.RealityKit/documentation/RealityKit/BindTarget/transform`` on the bound entity.
> Ensure a correct bind target is supplied when creating the animation.

## Topics

### Initializers

[`init(revolutions: Float, localAxis: SIMD3<Float>, timingFunction: AnimationTimingFunction, isAdditive: Bool)`](/documentation/RealityKit/SpinAction/init(revolutions:localAxis:timingFunction:isAdditive:))

Creates a new spin action.

### Instance Properties

[`var animatedValueType: (any AnimatableData.Type)?`](/documentation/RealityKit/SpinAction/animatedValueType)

The type for the value that the action modifies over time.

[`var isAdditive: Bool`](/documentation/RealityKit/SpinAction/isAdditive)

A Boolean value that indicates whether the animation system additively blends the action’s output with the base value.

[`var localAxis: SIMD3<Float>`](/documentation/RealityKit/SpinAction/localAxis)

A vector that describes the axis of rotation (in local space).

[`var revolutions: Float`](/documentation/RealityKit/SpinAction/revolutions)

The number of rotations to complete before stopping.

[`var timingFunction: AnimationTimingFunction`](/documentation/RealityKit/SpinAction/timingFunction)

A timing function that controls the progress of the animation.

## Relationships

### Conforms To

[`EntityAction`](/documentation/RealityKit/EntityAction)

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

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

---

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)