---
title: FromToByAction
framework: realitykit
role: symbol
role_heading: Structure
path: realitykit/fromtobyaction
---

# FromToByAction

An action that starts, stops, or increments by a specific value.

## Declaration

```swift
struct FromToByAction<Value> where Value : AnimatableData
```

## Overview

Overview This action animates a bound parameters value over time. Specifying a from value represents the animated properties’ initial value at the start of the animation. Specifying a to determines the value of the property at the end of the animation. Specifying aby adds a value to the properties initial state, which calculates the value at the end of the animation. This action exposes FromToByAction.TransformMode which is used when animating a Transform property. Use this mode to determine the reference space the property is relative to. For example, FromToByAction.TransformMode.local means the provided transforms are relative to the transform of the bound entity. The only exception is when by is specified, this is relative to the space of the starting transform. note: FromToByAction doesn’t support JointTransforms or BlendShapeWeights types. Use FromToByAnimation to animate these types. Creating a from, to, by action to animate an entity’s opacity The example below creates an animation which gradually animates the bound  entity’s opacity property for five seconds with a linear transition. In this example, the entity starts with opacity at 1.0. // Create an action that gradually animates a float value // towards `0.0`, with a linear transition. // // This action does not have a `from` value supplied,  // meaning this starts from the default source value. let opacityAction = FromToByAction<Float>(to: 0.0,                                           timing: .linear,                                           isAdditive: false)

// A five second animation that plays an animation causing the entity to // gradually animate the `.opacity` property towards `0.0`. // // This makes the entity fade-out. let opacityAnimation = try AnimationResource     .makeActionAnimation(for: opacityAction,                          duration: 5.0,                          bindTarget: .opacity)

// Play the five second animation on the entity that will fade-out. entity.playAnimation(opacityAnimation) Create a from, to, by action to animate an entity’s transform property The example below creates an animation which gradually animates the bound entities transform property for five seconds with a linear transition. // Create a transform to start animating from. let startTransform = Transform(translation: [0.0, 2.0, 0.0])

// Create a transform to animate towards. let endTransform = Transform(translation: [0.0, -2.0, 0.0])

// Create an action that gradually animates a transform value. // // This starts `from` a specified value, and animates towards // a specified `to` value. // // The bound entity will move in the space relative to its parent. let transformAction = FromToByAction<Transform>(from: startTransform,                                                 to: endTransform,                                                 mode: .parent,                                                 timing: .linear,                                                 isAdditive: false)

// A five second animation that plays an animation causing  // the entity to gradually move from a specific start, and end transform let transformAnimation = try AnimationResource     .makeActionAnimation(for: transformAction,                          duration: 5.0,                          bindTarget: .transform)

// Play the five second animation on the entity that will cause it to move. entity.playAnimation(transformAnimation) note: The default source value is the base value of the of animated property. If multiple animations target the property, then the framework observes the output of the previous animation as the subsequent animation’s default source value. important: This action animates various bound properties, for example BindTarget.transform on the bound entity. Ensure a correct bind target is supplied when creating the animation. note: For more information on the combination of inputs this action supports see FromToByAnimation. important: If you do not provide values for any of the from, to, and by parameters, the animation stays at the default source value.

## Topics

### Initializers

- [init(by:timing:isAdditive:)](realitykit/fromtobyaction/init(by:timing:isadditive:).md)
- [init(from:by:mode:timing:isAdditive:)](realitykit/fromtobyaction/init(from:by:mode:timing:isadditive:).md)
- [init(from:by:timing:isAdditive:)](realitykit/fromtobyaction/init(from:by:timing:isadditive:).md)
- [init(from:timing:isAdditive:)](realitykit/fromtobyaction/init(from:timing:isadditive:).md)
- [init(from:to:mode:timing:isAdditive:)](realitykit/fromtobyaction/init(from:to:mode:timing:isadditive:).md)
- [init(from:to:timing:isAdditive:)](realitykit/fromtobyaction/init(from:to:timing:isadditive:).md)
- [init(to:by:mode:timing:isAdditive:)](realitykit/fromtobyaction/init(to:by:mode:timing:isadditive:).md)
- [init(to:by:timing:isAdditive:)](realitykit/fromtobyaction/init(to:by:timing:isadditive:).md)

### Instance Properties

- [animatedValueType](realitykit/fromtobyaction/animatedvaluetype.md)
- [by](realitykit/fromtobyaction/by.md)
- [from](realitykit/fromtobyaction/from.md)
- [isAdditive](realitykit/fromtobyaction/isadditive.md)
- [isReversible](realitykit/fromtobyaction/isreversible.md)
- [mode](realitykit/fromtobyaction/mode.md)
- [timingFunction](realitykit/fromtobyaction/timingfunction.md)
- [to](realitykit/fromtobyaction/to.md)

### Enumerations

- [FromToByAction.DecodingErrors](realitykit/fromtobyaction/decodingerrors.md)
- [FromToByAction.TransformMode](realitykit/fromtobyaction/transformmode.md)

### Default Implementations

- [Decodable Implementations](realitykit/fromtobyaction/decodable-implementations.md)
- [Encodable Implementations](realitykit/fromtobyaction/encodable-implementations.md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [EntityAction](realitykit/entityaction.md)

## See Also

### Built-in actions

- [BillboardAction](realitykit/billboardaction.md)
- [EmphasizeAction](realitykit/emphasizeaction.md)
- [ImpulseAction](realitykit/impulseaction.md)
- [OrbitEntityAction](realitykit/orbitentityaction.md)
- [PlayAnimationAction](realitykit/playanimationaction.md)
- [PlayAudioAction](realitykit/playaudioaction.md)
- [SetEntityEnabledAction](realitykit/setentityenabledaction.md)
- [SpinAction](realitykit/spinaction.md)
