Working with Timelines

We can use RealityKit Timelines to add interaction and animation to our scenes.

Overview

Timelines in RealityKit are a feature of Reality Composer Pro. Understanding timelines means learning three concepts

  1. Behaviors trigger a timeline. See Working with Behaviors for a breakdown of the options.
  2. Timelines are containers for one or more Entity Actions.
  3. Entity Actions can update entity components. See Working with Entity Actions.

We don’t add Timelines directly to Entities. Instead, we add a Behaviors component, select a behavior, and select a timeline to run when the behavior is triggered. Adding a Timeline is simple. In your Reality Composer Pro scene make sure to select a Timelines. If your scene has no timelines, click Create Timeline.

Create a timeline

The section on the left shows a list of Timelines in our scene. We can add as many as we need. Rename them and reorder as needed. Select one to see its content in the middle section. You can find a list of Entity Actions on the right.

A list of Timelines, Earth Timeline Content, and A list of Actions

The workflow is generally something like this.

  • Create and name a timeline. These names show up in the Behaviors component when selecting timelines.
  • Drag actions into the timeline region
  • Edit the actions
    • Target them to entities in the current scene
    • Adjust parameters and timing
  • Test the timeline using the playback controls
  • Add a Behaviors component, then add a behavior that runs a timeline

Looping Timelines

Sometimes we may want to create a timeline that plays on a continuous loop. You’ll notice that the Entity Actions don’t seem to provide a way to loop. The way we do this is a little different.

  • Create a new timeline. We like to name ours with a Loop prefix. For example, LoopRocketFlight
  • With the Loop timeline selected click and drag one of the other timelines into it.
  • The one we dragged in becomes an action or child of the Loop timeline. Select it and look in the inspector region for the Repeat Forever option.

See this short video for an example of add child timelines to a Loop timeline.

Other Notes

We can compose timelines from other timelines. The Loop example above is one use case, but not the only one. We could create several small timelines that each take care of a certain part of our sequence. Then we could compose them together into a single timeline that can be played by a behavior.

In addition to triggering these timelines with Behaviors, we can also play in code as animations. We’ll cover that in and more in some upcoming examples.

Download the Xcode project with this and many more examples from Step Into Vision.

Some examples are provided as standalone Xcode projects. You can find those here.

Questions or feedback?