# Channel Link

{% embed url="<https://youtu.be/KxokUJnA8LY>" %}

Linking channels provides a way to combine the animation data of one channel with another. Channels are linked together similar to using patch cables, routing data from one channel to another to form chains of connected behaviors.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FhSUrTj2GaoCmikHIqdb6%2Fimage.png?alt=media&#x26;token=411183f1-efe9-4b74-8c86-532695261363" alt=""><figcaption></figcaption></figure>

Linking channels is also a great way to replicate behavior across multiple objects. Instead of having a bunch of duplicate behaviors and animations to manage, one can use a single master object and then link others to it. This can be used to directly copy animation or to modify it through additional calculations.

### Linking Channels

To the right of each channel name is a circular well. Clicking and dragging on this draws out a link cable which can be connected with any other channel well. Available link wells are highlighted by white circles as shown below.&#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FGgJHia0bXHgOxzRkbBTx%2Fimage.png?alt=media&#x26;token=42f5f40b-40c3-446e-92a5-f1c58df3c441" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Any link wells not highlighted in white may not be linked to. This may be to prevent circular references, or due to an incompatible data type. &#x20;
{% endhint %}

Each channel may be connected to 1 other channel, using it as data input. This can be set to overwrite the existing channel data, or use a math expression to calculate a new value. Channel links can be daisy chained to create complex behaviors, or to replicate a channel animation across multiple objects.&#x20;

{% hint style="warning" %}
The connection line appears red anytime dragging over an invalid selection. Releasing the drag while the line is red cancels the operation and no change is made.
{% endhint %}

### Linking with Drag and Drop

A handy shortcut to simultaneously create and link a new channel is to drag the object onto the link well of the source object.&#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FpyPn8d0nvGA2UeCFeN5p%2Fimage.png?alt=media&#x26;token=1cce4e2b-9ee7-494d-92aa-f01798559c9a" alt=""><figcaption><p>Note that a link is only created when the object is dragged and dropped on the channel link well (highlighted in white).</p></figcaption></figure>

In the example shown, the *Cylinder* object is dragged onto the *Sphere Local Position* channel link. This then creates a matching *Local Position* channel on the Cylinder and links it to the Sphere's position.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FBbHwGS4fmrSEC27mPiMx%2Fimage.png?alt=media&#x26;token=005136f5-e63a-430c-8e1c-920d7127d17e" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
This operation also works with multiple objects, creating and linking a new channel on each object.
{% endhint %}

{% hint style="warning" %}
In the event that the receiving object does not have a matching property, a [data-only](https://axongenesis.gitbook.io/timeflow/user-guide/properties#data-only-properties) channel is created instead. This can occur if the source channel is mapped to a component property that doesn't exist on the receiving object (i.e. doesn't have the same components).&#x20;
{% endhint %}

### Link Direction

Each channel has the ability to be linked *to* another channel (receiving the other's data) or linked *from* another channel (providing its data to that channel). This is depicted by the well icon as shown below.&#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FeEbFOd5qrf2IMHwn07Un%2Fimage.png?alt=media&#x26;token=33d6f33e-d707-4348-946d-4114f4718039" alt=""><figcaption><p>Note that the color of the link is based on the source channel color, which is blue in the example shown. </p></figcaption></figure>

{% hint style="info" %}
When the channel link is selected, small notch may be seen traveling along the line in the direction of data flow, as an aid to visualize the link relationship.
{% endhint %}

{% hint style="warning" %}
Each channel may only have 1 link input (linked to), but unlimited outputs (linked from).&#x20;
{% endhint %}

#### Linked To ![](https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FDA9cMInox3WznhhKBRbg%2Fimage.png?alt=media\&token=83e94d71-cfc6-4633-bf85-c602e573da30) (Receiving Data)

When a channel link is receiving data, its link is filled with the color of the source channel. By default the source data overwrites the receiving channel data, but may be configured to process the data further as described below in [Additional Settings](#additional-settings).

#### Linked From <img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2F4S9jneV90fUS2RxFwwPm%2Fimage.png?alt=media&#x26;token=262f8c25-35d6-4e89-a00d-de0be050696a" alt="" data-size="line"> (Providing Data - read only)

When a channel is being referenced by other channels (i.e. providing its data), its link well is outlined with its own channel color, to represent outward flow of data.&#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2Fhw8Wx3NSitUA87SU0Fi3%2Fimage.png?alt=media&#x26;token=1659a59f-8f1c-466e-849a-24d34b819fee" alt=""><figcaption></figcaption></figure>

In the example above, an extra [data-only](https://axongenesis.gitbook.io/timeflow/user-guide/properties#data-only-properties) channel (*Data Process*) has been added to perform additional calculation, which is then linked to by *Capsule Local Position*. Using intermediate channels in this way is useful to perform multiple calculations.

### Showing Links

To avoid screen clutter, channel link lines are only displayed for selected channels. If nothing is selected, only the link fills and outlines are shown (without lines).

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FMhulOq1C4HuYwaRAInLs%2Fimage.png?alt=media&#x26;token=c0e15a60-1011-4ea1-a96d-84cab766abaa" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Hold the **Alt** key to temporarily show all channel link lines, as shown above. &#x20;
{% endhint %}

### Removing Links

Channel links can be removed using the context menu options as explained in the section below. You can also hold the **Control** key and click on the link well to remove a link. This can only be used on destination links (Linked To).&#x20;

{% hint style="success" %}
While holding the **Control** key, any link wells that can be removed are displayed with a red minus icon ( - ).&#x20;
{% endhint %}

### Disabling Links

Channel links can be disabled without removing them by holding the **Alt** key and clicking on any receiving link wells (with filled color). Disabled links are displayed in gray and no longer processed.

![](https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FJYCtfynXDNf7kPmPS0I4%2Fimage.png?alt=media\&token=396b65a4-25f4-4cad-b02b-47f10fb0a16f)

The linked from channel only shows a gray outline if all referencing channels (linked to it) are disabled. If any channel link is still enabled, it displays the outline in color. The helps indicate when channel links are active or not.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2Fxlg6bFj3aSvdhY17cmRu%2Fimage.png?alt=media&#x26;token=387a3d3e-3428-428c-84d8-cbbc6ce9b14b" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
When a channel link is disabled it is treated as though it doesn't exist and the channel resumes normal behavior. It may be helpful at times to temporarily disable a link while preserving its settings otherwise.
{% endhint %}

{% hint style="warning" %}
**Animating Channel Links?**

It may be tempting to animate Link Blend or other parameters of channel links, however this is prohibited and it is not possible to animate channel link parameters. Instead, additional [data-only](https://axongenesis.gitbook.io/timeflow/user-guide/timeflow-view/properties) channels may be added to perform additional processing.&#x20;

If the result you are trying to achieve is more complex, it may be better to write a [custom script or channel link](#custom-channel-link) as described below [#custom-channel-link](#custom-channel-link "mention").
{% endhint %}

## Editing Channel Links

When a channel is selected, the link settings are displayed in the Info panel below.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FbdUUPH11u3DbLxz5ovxt%2Fimage.png?alt=media&#x26;token=c4434e31-00d6-4f5d-abd2-b8155c3178e3" alt=""><figcaption></figcaption></figure>

### Link Blend

This slider controls how much of the source data is combined with the current channel. If blend is set to 0, then the current channel remains unchanged from its present value, whereas a blend of 1 applies the data fully. How the blend is calculated depends on the math expression selected, described below in [Link Mode](#link-mode).

The [Graph View](https://axongenesis.gitbook.io/timeflow/user-guide/timeflow-view/graph-view) can be helpful for visualizing the result of channel link calculations.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FKOA0tX4P365AnguX45je%2Fimage.png?alt=media&#x26;token=4fafda90-b9c1-4c23-a545-16a042eabe9c" alt=""><figcaption><p>Shows a Link Blend value of 0, where the current blue animation curve is unaffected.</p></figcaption></figure>

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2F5osa1a29H7AKMIewppXv%2Fimage.png?alt=media&#x26;token=05feb6a6-e156-40d1-9050-8b2b46fa6f45" alt=""><figcaption><p>Shows the result of partially blending the source data with the current channel animation.   </p></figcaption></figure>

{% hint style="warning" %}
The receiving channel must have at least 1 keyframe for blending or when using any mode other than Overwrite. If the channel does not have any keyframes, then a warning similar to below is displayed.\ <img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2Fne03qgRxfjMZl6Qgazp5%2Fimage.png?alt=media&#x26;token=ab8bd457-c3b6-4dac-b587-cba954775417" alt="" data-size="original">
{% endhint %}

### Additional Settings

More settings can be exposed by clicking the pencil icon (to the right of the Link Blend slider). This also reveals a minus icon ( - ) which removes the channel link if clicked.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FsCzgx2mkmvS2ShNNpV1C%2Fimage.png?alt=media&#x26;token=4d098908-2d6f-4069-bf08-371ac1f78f91" alt=""><figcaption></figcaption></figure>

### Source

This displays the object and source channel being linked to. This field can be modified directly by dragging and dropping another TimeflowObject. The available channels to link to are displayed in the drop-down menu next to the object field.&#x20;

### In Attribute

This drop-down menu selects which attributes are used for input. This is only available for complex value types. Primarily this is useful to link a single axis from a complex value (vector, color, rect) to a single float value.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FFBeKgQpVxQ6xmCd6uiN6%2Fimage.png?alt=media&#x26;token=648f893a-964b-4899-bd04-e20ae784c485" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Note that the Out Attribute is disabled since it must match the channel it belongs to.
{% endhint %}

### Smooth

Applies temporal smoothing (in seconds) to the input value. Set to 0 to disable.

{% hint style="info" %}
Smoothing averages input values over time. Use this to reduce noise and blend values more gradually over time.&#x20;
{% endhint %}

{% hint style="warning" %}
Smoothing is only available for numeric and color data types.
{% endhint %}

### Time Offset

A time offset (in seconds) can be applied to delay or anticipate the source animation. This could be used for example to have one object, or a series of objects, follow a lead object spaced out over time.

{% hint style="info" %}
**Data Cache Optimization**\
When data is requested (which may be at times other than the current time), the source channel calculates the value internally but does not apply it to the object. A smart context-aware form of data caching is used to optimize repeated requests, so that the channel doesn't reprocess the same data.&#x20;
{% endhint %}

### 1st Key

This option is used with Time Offset. When enabled, the first keyframe on the channel sets the channel link time offset. Dragging the keyframe in time sets the channel link time offset. This can be helpful to manage link time offsets in the track and graph view.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FW7e9oEFeXz6PF39XdxME%2Fimage.png?alt=media&#x26;token=6f3a65e9-9a6d-4c0f-a058-f8e82b504373" alt=""><figcaption></figcaption></figure>

#### Negative

If this checkbox is enabled, the 1st keyframe time is applied as a negative time offset (instead of positive).

## Time Scale

Apply time scaling to the linked animation to speed it up or slow it down relative to the source animation.

## Link Modes&#x20;

Channel data may be processed with one of the following mathematical operations or using a custom function.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FK1jZ1WXhXqGWYv1uzcQ6%2Fimage.png?alt=media&#x26;token=708ed214-7425-494b-9c31-2809df39195c" alt=""><figcaption></figcaption></figure>

### Off

Disables the link. No processing is performed and the link is ignored when this mode is selected.

### Overwrite

This replaces the current channel data with the source channel data. This is a good mode to use for 1:1 copying of data from one channel to another. If blend is at full strength (1), then the current channel data is fully overwritten.

### Add / Subtract / Multiply

This adds, subtracts, or multiplies the source data with the current channel data. These modes are useful to augment an animation by offsetting, reducing, or amplifying it.&#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2F9mE1pP3NrK1A40aPhpik%2Fimage.png?alt=media&#x26;token=1132e4f2-2233-477d-8fbd-003517dceecb" alt=""><figcaption><p>An example showing Multiply, using an animation curve to envelope another.</p></figcaption></figure>

{% hint style="info" %}
Since both the source and destination channels can have their own animations, channel links can be used to create complex curves using simple techniques. &#x20;
{% endhint %}

### Min / Max

These modes are based on the math operations min() and max(). Min compares 2 values and returns the smaller of the two, while Max returns the greater of the two. This can be used to limit values or to perform boolean type operations between animation curves.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FogCclaYAuwII3fInwX3p%2Fimage.png?alt=media&#x26;token=d2cac05e-485d-43c1-8e88-b6945a346904" alt=""><figcaption><p>An example using Min, akin to a Boolean intersection.</p></figcaption></figure>

### One Minus

Use this mode when the source data is a value between 0 and 1 to get the complimentary value.&#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FBCSxG88kFJQEKPxAI6Dz%2Fimage.png?alt=media&#x26;token=d23e56d0-f1ce-4ee9-b9b4-71734dea0799" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
To invert or mirror data that isn't clamped between 0 and 1, use the Subtract mode and set an initial keyframe value of 0.
{% endhint %}

### Remap

Use remap to scale values from an input range to an output range. This can be helpful when mapping one property to another with a different value range.&#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2F2ecAfwjEqVkpWNydXQkM%2Fimage.png?alt=media&#x26;token=59e917aa-41fa-4cd9-975e-16c5e0d89fbb" alt=""><figcaption></figcaption></figure>

## Custom Channel Link

A custom channel link operation can be defined by writing a simple script. This is implemented using a ScriptableObject. Your custom script must derive from the base class CustomChannelLink and use override functions to implement custom behavior.&#x20;

{% hint style="info" %}
This documentation assumes you are familiar with Unity scripting. Please see CustomChannelLinkDifference.cs for example code and refer to the comments for further details about the implementation.
{% endhint %}

### Create Object Instance

To assign a custom channel link, an instance of the ScriptableObject must be created as an asset first. This is a one-time setup after which the object can be assigned in the channel link settings.&#x20;

{% hint style="success" %}
Right-click in the Project view and select **Create > Timeflow > Create Channel Link**
{% endhint %}

![](https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FadklLAYubjgkrV8bL0KC%2Fimage.png?alt=media\&token=34545e92-c4c5-4875-bc9e-3a8ce44630bb)

Once created, the custom link can be dragged from the project window to the custom link field in the mini inspector, as shown below.

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FpGMas0hSwzVMfnfeUlSm%2Fimage.png?alt=media&#x26;token=e6016d34-2903-402d-8748-412e66ab11ef" alt=""><figcaption></figcaption></figure>

For more commands and menu options related to channel links, see [Channel Link Menu](https://axongenesis.gitbook.io/timeflow/user-guide/timeflow-view/broken-reference).
