Transition Libraries

Transitions each define how to play a specific animation state regardless of what was playing before. If you use Transition Assets, you can put them in a TransitionLibraryAsset which allows their fade durations to be modified depending on the previous animation to fine tune what each transition combination looks like without any additional code.

Samples

Sample Demonstrates
Library Character How to use a simple library to modify some fade durations.
Named Character How animations can be given Aliases in a library and then played without needing to be directly referenced.
Animation Serialization How a library can be used as a central list of animations so that their index in that list can identify them in order to do things like saving animation details to a file or sending them over a network.

Library Window

A library can be created using the Assets/Create/Animancer/Transition Library menu function. Then you can Double Click it or use the Edit button in its Inspector to open it for editing.

# Name Description
1 Pages A dropdown menu to change between the Modifiers and Aliases pages.
2 Asset Path The asset path of the library being edited. Click to select it. Click again to ping it in the Project window.
3 Revert Undo any changes made in the window.
4 Apply Save any changes made in the window to the library.
5 Auto Toggle on to immediately Apply any changes as soon as they're made. This is particularly useful in Play Mode if you want to see the effects of each change as you make them. This option will automatically be disabled when leaving Play Mode so you can choose whether to Apply or Revert the changes when back in Edit Mode.

Modifiers

The Transition Modifiers page allows you to define how the library modifies specific transition combinations as demonstrated in the Library Character sample.

# Name Description
1 Create Transition Create a new Transition Asset as a sub-asset of the library.
2 Remove Transition Removes the selected Transition Asset from the library. If it's a sub-asset of the library, this will also delete it. Otherwise, it gives you the option to either delete it or just remove its reference from the library.
3 Headings All transitions in the library are listed in a table. The rows down the left specify the previous animation a particular combination is coming From and the columns across the top specify the new animation it's going To. Selecting a column or row allows you to edit that transition in the Inspector. Note that these edits take effect immediately and are unaffected by the Apply and Revert buttons because you're editing the selected Transition Asset which isn't actually part of the library.
4 Default Fade Cells containing small text mean there is no modifier for that combination so it will use the fade duration defined in the To transition. Simply click in a cell and type a number to create a modifier there.
5 Modified Fade Cells containing bold text contain modifiers. Clearing a cell will remove its modifier.

For example, in the above image:

  • The small numbers in the Shoot column show its default fade duration of 0.1.
  • The bold 0.05 where the Walk row intersects the Shoot column indicates that it has a modified value.
  • So if the character was playing Walk and is told to Shoot, it will take 0.05 seconds instead of the default 0.1.
  • The script playing Shoot doesn't need to know that the library is present, the modifier is applied automatically.

Creating Transition Assets

As mentioned above, Transition Assets can be created using the Create Transition button in the library window which automatically adds them to the library and saves them as sub-assets inside the library itself.

They can also be created separately using the Assets/Create/Animancer/Transition Asset menu function and then dragged into the library window to add them to it. Doing so won't turn them into sub-assets, it will just give the library a reference to them just like anything else.

Unity doesn't have an inbuilt way to turn assets into sub-assets or vice versa without scripting, but Inspector Gadgets Pro has a Drag and Drop Sub-Assets feature which lets you do exactly that.

Previews

Selecting a modifier cell shows its details in the Inspector with a preview so you can see what it will look like as you tweak it.

Aliases

The Transition Aliases page allows you to assign custom names to transitions so they can be referred to by name instead of always needing direct references as demonstrated in the Named Character sample.

# Name Description
1 Alias All Transitions Should every transition in the library be automatically given its name as an alias?
2 Add Alias Each transition is shown in the list with this button to add an alias for it.
3 Remove Alias Each alias has a button to remove it.
4 Alias Each alias allows you to assign a String Asset which can then be used to refer to the transition it's listed under.

With an alias defined, scripts can use AnimancerComponent.TryPlay(alias) to play it without having a direct reference to the Transition Asset.