Search Unity

dynamic timeline values

Discussion in 'Timeline' started by SomehowLuke, Oct 15, 2019.

  1. SomehowLuke

    SomehowLuke

    Joined:
    Nov 11, 2015
    Posts:
    34
    Hello,
    I was wondering if there is a possibility to have dynamic values for timeline-animation.

    What I want to achieve:
    After the player finishes a level an "finish level" animation sequence starts to show up and shows the result of played level (in this example player reached 75% of 100% and to finish level he has to reach 50%).
    example sequence: Cake diagram zooms in, progress bar must have % fills up, (image.fillamount = 0 to 0.5f) after that the reached % progress fills up, once the animation reached must have a particle effect will be played, once the reached is at its point (image.fillamount = 0- 0.75f) it zooms back to its original point.

    This is just an example and short sequence shown, the one I want to build is a little more complex.

    What I do now:
    is having a c# code sequence (with DOTween) that follows all these steps. But to change or add animation steps it is kind of hard for artists to do and alsways need to explain me, as an non artist, what they want to achieve, what kind of sequences should be added.

    What I would like to achieve:
    I would like to use the timeline to create this sequence and using variables that I fill by code. For example: I have a "timeline-variable" float fReachedPercentage which I can dynamically set in my code. The artists sets the timeline animation of image.fillamount from 0 to fReachedPercentage (and not a fixed value).
    So I want to have always the same animation sequence, but the value to what it should animate is dynamically.

    Is that somehow possible?
    Thank you very much for your help and best regards,
    Markus
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    It is definitely possible, although it requires some custom scripting in timeline, and would of course depend on the use case.

    A clip which takes the appropriate image and monobehaviour (as ExposedReferences) and simple calculates the current fill amount based on the time and duration of the clip is the first thing that comes to mind.

    Something like

    image.fillamount = playable.GetTime() * otherScript.acheivedProgress / playable.GetDuration();

    would cause timeline to set the bar to the appropriate level at the given time.

    You could use a more advanced formula to get the blend in/blend out scenario you described. Or use an animated parameter value. Or have a second clip that does the blend out.

    The point being, yes it is possible. And it's not hard to achieve.
     
    SomehowLuke likes this.