Skip to content

How to use in Unity

Daedalus edited this page Oct 4, 2026 · 8 revisions

Installation in Unity

  1. Create a folder AvatarAnimator in your Unity project.
  2. Copy All files in the Unity/ folder of this repo into your project.
  3. Also Copy PlayerAnimatorCore.cs and Utils.cs into your project.
  4. On an Unused GameObject, outside an avatar, add AvatarAnimatorTestScript to be able to tests AvatarAnimator on your Avatar directly in Unity.

Pre-requirement to use AvatarAnimator on your Avatar

  1. If not already done, create an Animator Controller and apply it on your Avatar Animator.
  2. Add the script Avatar Animator Data Container on the same GameObject that the Animator.

image

In the Animator Controller

  1. Create or rename the layer to start with AvatarAnimator.

    1. If you create it, don't forget to set it's weight to 1.
    2. You can create multiple Layers as long as they start by AvatarAnimator.
  2. Add your Animation clips and the transition between them. (Read How to make transitions below)

  3. In the Parameters tabs, you can add different types of parameters that are handle by the mod.

  • As Tigger: Input=...
    Put this to animate using your inputs.

Input=<Type>:<Key1>(+<Key2>);<Type>:<Key>
<Type>: Keyboard, Controller
<Key>:
Keyboard:<KeyCodeName> KeyCodeNames
Controller:<ControllerInputs> ( A B X Y LeftGrip RightGrip LeftTrigger RightTrigger Menu SecondaryMenu LeftThumbStick RightThumbStick LeftTouchPad RightTouchPad)
Exemple: Input=Keyboard.Y;Controller.LeftThumbStick

  • As Int: Random(max)
    Put this to select a random transition among multiple.
    Change max to the number of transitions from a state.
    And for each transition set it to Equals and a coresponding number between 0 and Max-1.

  • As Float: Health
    Put this to Animate using the health of your avatar.

  • As Float: Timer
    Put this to play an animation after some time.
    And for each transition set it to Greater and the number of sec

  • As Int: Cyclic(Count)
    Put this to select a transition cyclicly among multiple.
    Change Count the number of transition from a state.
    And for each transition set it to Equals and a coresponding number between 0 and Count.

  • As Tigger: WaitEndClip
    Put this to wait for the clip to stop playing completly once before allowing the state change.

Once done, add in the transition, the condition(s) to change to the next state.

Animator

If a transition doesn't have a condition don't forget to chech Has Exit Time otherwise it will be stuck on this transition. And if it has condition(s) uncheck it.

To Trigger a transition to another animation clip, you have to validate all Conditions. If you want to have multiple conditions but only a part are required to trigger the transition, simply add other(s) transition between the same animations with each part of the condition.

It is possible to have an Animation without transitions IN and/or OUT. In that case, this animation can only be played or exited manually.

How to make transitions

Cyclic

Cyclic

This is the most simple way to set transitions between multiple Animation. Doing this can allow you to use only one trigger Input to iterate through every animation. But you have to play every animation that are between the animation that you want and the one currently playing.

Forth and back

F&B

For this one you can ether use multiple Inputs for each Out transitions or use Random or Cyclic to select one using only one Input.

After in the script

image

All the logs of the buttons are writen in the mini console below the buttons.

  1. Once you are done with the Animator Controller, push the Populate Data button.
    This will trigger the collect of the Controller data and check if there is any mistake.
    Each red messages indicate an error that must be corrected.

  2. You can use the Test Data button to look at the collected data.

  3. Once your are done, use Serialize Data to store the data of your Controller as a string in Serialized Data field.

  4. You can now pack the pallet like normal.

Add Audio

Audio clip can also be played using Animation clip. To do that,

  1. Import your audio clip(s).
  2. Add on your Avatar an Audio Sources, add your audio clip, check Play on Awake and Disable the component.

image

  1. Go into your Animation clip and add the property Audio Sources.Enabled.
  2. at 0.00 Disable, 0.01 Enable, <Clip Duration> Disable.

image

Note: If you want the audio to only be played once, you can ether uncheck Loop Time of the Animation clip or duplicate the layer and clips with uncheck loop. In this precise case, you dont have to name the layer to start with AvatarAnimator since it's a copy of all the states, transitions and transitions conditions, if the conditions are validate in one layer it's validate in every layer. But it can produce desync if a state is played manually.

Testing In Unity

image

If not already done, Add on an unused GameObject and outside Avatar, AvatarAnimatorTestScript. (It's normal that it's empty read the rest.)
To test your Animation on your avatar, once you use Serialize Data, Simply play your Unity project.
In the Unity tab Game not scene you can use your keyboard to test your transition. (Controller input are not available here)
Select the GameObject with the script AvatarAnimatorTestScript and like the image above, if everything was done correctly, just select the name of your avatar and manually change the state of your avatar.
Health, Cyclic and Random parameters are not automatically set after a transition like in the mod. They must be set manually using the test script.

In Bonelab

In the Bonelib menu there is a Menu for AvatarAnimator. Inside you can Play an animation manually.