💃Timeflow Controller

A script to control Timeflow playback at runtime

This component is used to start and stop playback, queue specific markers, hook into playback events, and play custom regions in time. Use Timeflow Controller for cutscenes or to play animations interactively based on user input or triggered events.

The Timeflow Controller provides a general API for working with Timeflow, however much more is possible with custom scripts (if needed). This controller is meant to provide basic functionality. If you are a developer with specific needs, you may choose to extend this script or create your own.

Play Mode

This sets the default play mode when the Play() method is called.

The play mode can also be set dynamically by script or event by calling one of the SetPlayMode methods.

One Shot

Plays through the designated time region once. When it reaches the end of the current area, playback stops. One Shot mode is typically used for cutscenes to play a specific section of the timeline just once and then stop.

Looped

Plays the current work area (or full timeline) repeating indefinitely. Use Looped mode to create living holds or sections of time that play repeatedly until interrupted by the user or some other event.

Continuous

This mode continues to play past the end of the current playback region. This mode is useful to keep looped animations such as tweens alive with continuous forward moving time.

Auto Play

This overrides the Timeflow auto-play settings to allow the controller settings to take precedence. If you want the animation to wait until it is triggered to play, turn off Auto Play.

Work Area

This determines whether the Work Area is used in Timeflow to constrain playback to a specific region in time. In most cases, the Work Area is desired to set the start and end time for the current marker being played, though it may be turned off to continue to play the timeline to the end, or until interrupted by another event.

Timeflow

Designates the Timeflow instance being controlled. Any other Timeflow instances in the scene will not be affected unless they are children of the target Timeflow.

Start At Marker

Queues Timeflow to play on scene start at the designated marker. A marker may be specified either by index (order in the timeline) or by name.

Events

The following events can be configured in the editor to perform additional actions and hook into playback events. These can be used to setup game logic in the editor without additional scripting. For more information, see the Unity Events documentation.

On Startup

This event is called once when the Timeflow Controller initially starts. This event is invoked during Start().

On Play

This event is invoked each time any Play method is called on the Timeflow Controller. Use On Play to setup additional logic when playing a section of time. For example, this can be used when playing cutscenes to disable player input and display dialog elements.

On Stop

This event is invoked once playback stops or reaches the end of the current time section. Use this event to return control back to the player after a cutscene and to hide any other elements displayed during playback.

On Skip

This event is invoke when Skip() is called, either by script or by an event. Use this event to perform additional logic when playback is skipped by the user or interrupted by another event.

Methods

The following methods are defined in the Timeflow Controller script and may be called wither by script or events.

SetWorkAreaStart(float startTime)

Explicitly set the start time of the playback region.

SetWorkAreaEnd(float endTime)

Sets the end time of the current playback region.

SetWorkArea(float startTime, float endTime)

Sets the start and end time of the current playback region in one call.

PlayFromMarkerIndex(int index)

Queue playback starting from the marker with the given index, automatically setting the time region up to the following marker.

PlayFromMarker(string markerName)

Queues playback of a marker region with a specific name, automatically setting the time range up to the next marker after it.

Using marker names is preferred in most cases since it is easier to read.

PlayFromMarker(TimeflowMarker marker)

Queues playback using a marker reference. This is called internally or by other scripts with a TimeflowMarker object.

PlayFromTime(float time)

Starts playback from a specific time in seconds.

PlayFromStart()

Starts playback from the beginning of the current work area, or the start of the timeline if the work area is off.

Play()

Resumes playing from the current time.

Skip(float padSecondsFromEnd = 0)

Advances time to the end of the current work area. If the pad time is set, the time is advanced to that duration before the end, to allow lead out time.

Stop()

Stops playback. This is also the same as pausing Timeflow. If Play() is called afterward, it resumes from the current tiem.

SetPlayModeOneShot()

Sets the current play mode to One Shot.

The SetPlayMode...() methods can be set by script or an event to prepare a cutscene or other section of time for playback. It's best to call this before Play().

SetPlayModeContinuous()

Sets the current play mode to Continuous.

SetPlayModeLooped()

Sets the current play mdoe to Looped.

Last updated