Contents

SpinAction

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

Declaration

struct SpinAction

Overview

This action rotates an entity around itself from a specified localAxis gradually adjusting its local transform. The 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.

// 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)

Topics

Initializers

Instance Properties

See Also

Built-in actions