Search Unity

How to handle multiple GameObjects in single Animation Track?

Discussion in 'Timeline' started by amitkavatkar, Aug 20, 2019.

  1. amitkavatkar

    amitkavatkar

    Joined:
    Aug 20, 2019
    Posts:
    1
    I am developing a 2D game using Unity Timeline. So the scenario is, I have added an animation clip having 3 GameObjects with the same animation. Is it possible to activate animation on single GameObject among those 3 at runtime?

    Example:

    If there are 3 balls having Red, Blue & Green colours on a horizontal plane like wood. If I have touched on Red ball, it should drop down i. e. Animation on Red ball should be triggered.

    Is it possible directly on the timeline? or Code?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can bind the the appropriate animator to a timeline at runtime before playing. The call do this is playableDirector.SetGenericBinding(track, animator). You can search for your track using the timeline asset and GetOutputTracks().

    Alternately you can have three playable directors, each using the same timeline, but a different binding and pick which one to play, or, all three.

    Timeline is an asset - similar to an animation clip - so it can be played by multiple playable directors.
     
    amitkavatkar likes this.