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. Dismiss Notice

Question Custom Animation Track

Discussion in 'Timeline' started by Sangemdoko, May 18, 2022.

  1. Sangemdoko

    Sangemdoko

    Joined:
    Dec 15, 2013
    Posts:
    215
    Hi,

    To give a bit of context, I'm trying to setup a workflow to create cinematics during dialogs in our game. Due to the branching dialogues we plan to have timelineAssets per dialogue card and not the other way around.

    We're are going to have 100s of cinematics if not 1000s.
    The playable Directors could be anywhere but I think it makes sense to set them on the gameobject that will trigger them (NPC, Trigger, Interactable, etc..)

    The cinematics need to blend seamlessly with gameplay (Top view, fixed camera angle).
    The player is spawned at runtime.
    It is important for us to be able to preview the cinematic in edit time to speed up the iterative workflow



    I created a custom Track to spawn the player character (and other dynamic objects) while in preview mode, if it does not already exist in the scene.
    I can get the preview character in my custom locomotion track used for moving, rotation, etc...
    I have markers in the scene with keys such that I can easily get positions in the scene while previewing

    So far everthing works as expected since it is all custom scripts...


    My main problem is the Animation Track. I can't find a good way to animate my player character in the timeline because it does not exist outside of the preview mode.

    I tried making a custom Animation Track by inheriting the default AnimationTrack but for some reason it does not record anything and it misses functionality like the TrackOffset and Override Track

    The main reason I need a custom Animation Track is simply such that I can assign it to a specific character using a scriptable object reference. This way my custom track that spawns the preview character can set the animator binding reference during preview.

    Another reason a custom Animation Track could be nice is simulating the animation that the player would have at runtime to test out different blending options in preview to see what works best for all scenarios.


    (I also tried copy pasting the Animation Timline source code, but it has references to so many internal scripts that I gave up the idea)


    Does any one have advice on how to make a custom Animator Track?
     
  2. ramzul

    ramzul

    Joined:
    Jul 7, 2015
    Posts:
    5
    public class PuzzleAnimatorTrack : TrackAsset, ILayerable
    {
    public override IEnumerable<PlayableBinding> outputs
    {
    get { yield return AnimationPlayableBinding.Create(name, this); }
    }

    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
    Animator animator= go.GetComponent<PlayableDirector>().GetGenericBinding(this) as Animator;

    foreach (var c in GetClips())
    ((AnimatorAsset)(c.asset))._animator = animator;

    return AnimationLayerMixerPlayable.Create(graph, inputCount);
    }
     
  3. UbiRose

    UbiRose

    Joined:
    Dec 10, 2021
    Posts:
    2
    Has there been any update for this? I would like to be able to do the same thing. Other than finding out about ILayerable, the response looks a little incomplete