Search Unity

Get smoothed UI Animations in Timeline Asset

Discussion in 'Scripting' started by alphakanal, Oct 26, 2020.

  1. alphakanal

    alphakanal

    Joined:
    Jan 21, 2013
    Posts:
    52
    Hi,

    i've got a scene where a my camera is flying around some 3D objects - this is done via cinemachine dolly track.

    I've animated the Cameras path position within a timeline asset and scrubbing through the timeline via my mouse-wheel using this scipt:
    Code (CSharp):
    1. public class TimelineControl : MonoBehaviour
    2.  
    3. {
    4.     public PlayableDirector playableDirector;
    5.     private float animTime = 0f;
    6.     private float animTimeTemp;
    7.     private float speed = 0.1f;
    8.  
    9.     void Start()
    10.     {        playableDirector.Play();    }
    11.  
    12.     void Update()
    13.  
    14.     {        ScrubThroughTimeline();    }
    15.  
    16.     private void ScrubThroughTimeline()
    17.     {
    18.         animTimeTemp = animTime;
    19.         if (Input.mouseScrollDelta.y < 0 && animTimeTemp > 0 )
    20.         {
    21.             animTime = animTimeTemp - speed;
    22.         }
    23.         if (Input.mouseScrollDelta.y > 0 && animTimeTemp < 10 )
    24.         {
    25.             animTime = animTimeTemp + speed;
    26.         }
    27.  
    28.         playableDirector.time = animTime;
    29.     }
    30. }
    Works fine BUT:
    I'm also animating a UI Textblock within the same timeline asset. The Text ( showing Infos about that specific object ) is flying-in when the camera is getting closer to a 3D object and flying-out when moving further away.

    Here's the "problem":
    When stop scrolling the mouse wheel, the movment of the camera along the path is perfectly dampening ( because of it's z-dampening settings on the cinemachine-virtual-camera component ) while the in/out animation of the infotext is stopping immediately ( of course ).

    Is there a way to add a "dampening" of the Text movement as well or do i have to make a diffenrent approach ( than timeline animation ) to get a smoothed-out text animation?

    Hope you know what I mean :)
     
    Last edited: Oct 26, 2020