Search Unity

Tranform tween track

Discussion in 'Timeline' started by sp-sergio-gil, Aug 19, 2019.

  1. sp-sergio-gil

    sp-sergio-gil

    Joined:
    Mar 5, 2014
    Posts:
    45
    I'm using the tranform tween track from the default playables package and is not working properly... If I move the timeline is not calculating correctly the initial and final position and is not finishing in the correct place...

    In the other hand, I'm using this code to setup the binding from code

    Code (CSharp):
    1. if (track is TransformTweenTrack && track.name == "Transform Tween Track " + index)
    2.                 {
    3.                     playableDirector.ClearGenericBinding(track);
    4.                     playableDirector.SetGenericBinding(track, go);
    5.                  
    6.                     foreach (var clip in track.GetClips())
    7.                     {
    8.                         var t = clip.asset as TransformTweenClip;
    9.                         if (t == null)
    10.                         {
    11.                             continue;
    12.                         }
    13.                      
    14.                         playableDirector.ClearReferenceValue(t.startLocation.exposedName);
    15.                         playableDirector.ClearReferenceValue(t.endLocation.exposedName);
    16.                      
    17.                         playableDirector.SetReferenceValue(t.startLocation.exposedName, Origin.transform);
    18.                         playableDirector.SetReferenceValue(t.endLocation.exposedName, fakeLayoutItemGameObject.transform);
    19.                     }
    20.                 }
    and is setting values properly (I can see them in the inspector) but then the object is not moving... If I do this manually, then again the transform is moved but not to the final correct position... any clue?

    Sergi Gil
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    If you are trying to change bindings while the timeline is playing, they won't be updated.

    You can call playableDirector.RebuildGraph() - but it's expensive, any definitely not recommended to do each frame.