Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Using timeline assets as gameplay templates

Discussion in 'Timeline' started by alireza_95, Jun 7, 2019.

  1. alireza_95


    Mar 3, 2018
    Hello There

    This is my first forum post so i hope you will excuse me for any unintended mistake in creating this thread

    Essentialy I am working on a character controller of sorts based on Playables and the Timeline and Timeline Assets and i have alot of questions about everything involving these subjects!
    Since Playables and Timeline are used in such a variety of ways and Timline is more for cinematic infused in to gameplay, I want to clarify my use-case and my view so if any one decided to help they can understand my problem better

    The result I want:
    designer decides to add a sword attack to the main character and he asks the art team for a sword attack. the art team give him a timeline asset containing the character doing the attack and all the sounds and particles involved. the designer edits the track and maybe adds a playable that contains attack logic to this timeline asset. this timeline asset is added to the characters action library. at runtime (preferably before) i build a playable graph hooking playables from all the timeline assets for that character creating a blendable character controller with behavior. I would off-course have to have a logic code to determine what action is done but that action will have a key that is mapped to many things including the weight assigned to that actions playablenodes in the graph.

    what do i achieve?
    i design a solid base for the characters actions what they can do and what they can manipulate i design the necessary blend-logic for those kinds of things. after that i only code a state-machine for these actions.

    So currently i have a logic code that generates a graph using many timeline assets ans i use logic keys to blend all the different playables

    so what problems or questions do i have?

    it is an issue i posted here:

    basically the animation playable from timeline actually sets the gameobjects position so when i try to set the gameobjects position the character jitters in 0,0,0

    and i wrote the bellow to post it there but after writing i thought it would be better to describe my exact use-case to better communication and potentially get more opinions on whether this is technically possible at all

    > The root motion flag on the animator will control whether to apply root motion - i.e.<

    this is not what i am experiencing. i have a timeline asset that has an animation track with an animation clip. i manually create a a playable from the timeline asset and created a playable graph and played it. i also have a code that u have ran in update and late update that moves the gameobject. the behavior i see is that the gameobject is constantly jittering leaving me to the conclusion that the gameobject position is being reset by the animation playable.

    and i had apply root motion set to false

    > As for creating & manipulating the playable graph, you should be able to useTimelinePlayable.Create(), but I would recommend passing in a gameObject with a playable director that holds the correct bindings for the timeline.<

    If i could somehow use the bindings set inside the playable director that would make everything much easier as i could see and edit all of the bindings for a character next to each other.

    2- To my understanding when the playable graph starts playing all the animations are moving forward so if after 30 frames of animation A i start blending to animation B I am blending to where animation B is after its 30ieth frame is this correct? if so is this somehow controllable?

    3- how performant is the playable graph at a large scale. like 20 outputs each with around 10 to maybe 100 inputs with maybe 10 mixers. How is the impact measurable?

    4- is there anyway to build this graph before runtime like how timeline does? to avoid process potential performance impact.

    5-anyway to preview physic effects in the timeline preview?

    6- how good are playables for accumulative behaviors in general? I know i have to do more personal testing but since i didn't see any examples on this in all of the resources i have looked while searching i have become a bit skeptical.

    for those few who have read through I thank you and if you have any idea on any of these questions I would be very thankful

    I am not a native englishs peaker so excuse any wierd mistakes i might have made
  2. seant_unity


    Unity Technologies

    Aug 25, 2015
    Building a state machine using timelines is challenging, mainly due to the limitations one output weighting. There are a few other posts on workarounds to accomplish this, but admittedly it's more complex than it should be.

    That being said, here are some suggestions:

    Use scene offsets & root motion on your animation tracks. Also, make sure clip offsets are aligned using the Match to Previous functionality. That should take care of most of the position/rotation matching issues.

    The simplest way to implement a state is a timeline that uses ease-in on the first clip, and ease-out on the last. Calling play on the playable director will blend the character to/from whatever it was doing (state machine or other timeline). Animators play a stack of outputs, where the base is always the animator controller, and the order is based on the order of play. This works well for states that aren't interrupted.

    Assuming both are on the same animation track, then no. Animation B should start blending from frame 0, unless the 'clip-in' value is set.

    The impact is usually measured by the # of tracks being played. I.e. How many characters are being animated, how many active layers do they have (i.e. override tracks, stacked timelines) and how many clips are actively blending (anything with a weight of 0 is culled). The cost of a timeline tracks is comparable to a animator controller.

    PlayableDirector.RebuildGraph() will build the graph but not play it. Most of the cost of timeline comes from the building of the playable graph, and that always occurs at runtime (the graph itself is not serializable).

    Unfortunately no.

    That depends on what you are trying to accomplish. Most animation in Unity uses playables, including the new runtime rigging feature. There is also support for animation jobs, so playables are quite flexible but have a relatively high learning curve.

    Overall, manipulating multiple timelines into a single graph is complicated. Timeline formats it's playable graph in a particular way, and trying to manipulate it after the fact is difficult. It is possible to build a custom animation track that is customized to your neededs, but the playable that control offsets for root motion are internal so certain functionality is hard to replicate.

    I hope that clarifies some things.
    alireza_95 likes this.
  3. alireza_95


    Mar 3, 2018

    Thank you very much

    I have shifted to pure playables currently to see what i can come up with, i just wish some of the really complete implementation of playables were not internal, being able to read how something like the animation track works is certainly more than enough to get the hang of playables in general.