Animation.SyncLayer Manual     Reference     Scripting  
Scripting > Runtime Classes > Animation
Animation.SyncLayer

function SyncLayer (layer : int) : void

Description

Synchronizes playback speed of all animations in the layer.

When blending between two looping animations they often have different lengths. For example a walk cycle often takes longer than a run cycle. When blending between them you need to make sure that the foot placement of the walk and run cycle happens at the same time. In other word playback speed of the animations must be adjusted so that the animations are synchronized. SyncLayer will calculate the average normalized playback speed of all animations in the layer based on their blend weight. Then it will apply that playback speed to all animations in the layer.

JavaScripts
// Puts the walk and run animation in the same
// layer and synchronizes their speed
animation["walk"].layer = 1;
animation["run"].layer = 1;
animation.SyncLayer(1);

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Awake() {
animation["walk"].layer = 1;
animation["run"].layer = 1;
animation.SyncLayer(1);
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Awake():
animation['walk'].layer = 1
animation['run'].layer = 1
animation.SyncLayer(1)