Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Move animations from code to timeline

Discussion in 'Timeline' started by sp-sergio-gil, Jul 31, 2019.

  1. sp-sergio-gil


    Mar 5, 2014
    Hi all!

    As a postmortem exercise, and after watching to all Ciro Continisio videos about using timeline creativity, I'm thinking if in the project it could be better to let more freedom to artists/designers using extensibely timeline instead of using custom animations that we did using code.

    From here I'm thinking in a concrete example:

    1. Open a UI popup
    2. Execute a timeline that shows a chest appearing, bouncing and exploding
    3. When chest explodes it shows X rewards that are moved to some top place in the popup

    Creating the chest appearing timeline could be super easy, but generating X random rewards could be more tricky... I'm thinking in having a track that can spawn rewards over the chest (at the moment with a list of prefabs that we manually fill and each of those rewards would contain a timeline with a "transform tween track" from default playables asset store package, that will do the movement), and after instantiating we setup the startLocation and endLocaltion and play the reward playable director to move it correctly as we need...

    Is this a good way of do things? the examples that ciro has all are fixed and very controlled.. I mean no generate dynamic thinks and as I said I want to avoid as much code as posible

    I was thinking that perhaps we need a control track to control the spawned timelines and play them correctly , but in this case I cannot figure out how to use it... do I need to create control tracks in runtime if I don't know how many rewards I will create??? does anyone have an example of creating something like this?


  2. sp-sergio-gil


    Mar 5, 2014
    anyone? no idea on how to tackle this issue? I'm really interested in finding a proper solution but after some testing I'm not confortable on how to fix it
  3. seant_unity


    Unity Technologies

    Aug 25, 2015
    I'd recommend trying to use a Signal (if you are on at least 2019.1). The Chest timeline just generates a signal that the chest has been opened, and then you can have a script that either
    * picks from a list of playable directors to start playing (if every item has their own animation)
    * picks from a list of prefabs/gameobjects, activates them, binds them to a single timeline/director and plays it. (if they all play the same animation).

    In scenario two, either a tween track, or a recorded animation would work just fine.

    If you are on pre-2019.1, you could do the same thing using a custom clip.

    Signals is one way to achieve 'dynamic' timelines. The idea is that a signal just indicates that a threshold has been past and the the game can react to it how it needs to, which may include playing another timeline.