Note: click here if you are using an older version of Zoe for Unity (1.x).
The Animation action allows you to trigger an animation. This action is using the Animator component from Unity. It means that any animation clip you want to play needs to be inside an Animator Controller and your object needs the Animator component attached. For details on how to set your Animator Controller, read the next section below.
Playan animation or
- Animator: here you need to drag the Game Object from your scene that has the Animator Controller attached.
- Trigger: Here you have the list of all ‘trigger transitions’ found in the specified Animator Controller.
The action reads the transition between clips from an Animator controller and the only type of transition read by this action is of type ‘Trigger’. To read a clip make sure you set a ‘Trigger’ condition on the transition.
Setting up an Animator Controller
To launch animations with Zoe for Unity you need to set up an Animator with the animations you want. An animator controller works as a ‘State Machine’ where every animation clip is a state of your object and there are transitions between the states, sometimes with conditions. For example, for a cat you could have the following states: Idle (cat is seated and moves its tail a bit), Walk (cat walks) and Meow (cat is meowing). Then you need conditions to go from one state to the other. The condition type that Zoe reads is the ‘Trigger’ one, the one you need to set in order to read the animations with the Animation Action. For this cat example, you would create a Trigger transition called CatWalks and CatMeows and you would set them in between states, targeting the Walk or the Meow state.
The animations or states of your animator can be either created in Unity or in a 3D animation software. Here are the two options on how to set your controller depending on the source of the animations:
- Using external clips: if you created your animations on a separate software then you need to import them embedded in your 3d model. FBX is the best and most suitable format to do this.
Inside Unity you need to create an Animator Controller that you will attach to your object.
To set your controller you need to open the Animator Window, the easiest way is to double-click on the Animator Controller you just created. Here you need to drag the clips from your FBX file. They will appear as states of the Animator. Now set the clip you want to play by default, right-click on it and select “Set as Layer Default State” it will then be attached to the ‘Entry’ element.
Then you need to create transitions between all your clips and to assign a Trigger condition for each. For this, go to Animator > Parameters on the left side of the Animator window. Click on the ‘+’ sign and select ‘Trigger’. Then name it as you want (we recommend using the name of your target state so you know which type of clip is going to play).
To create a transition between two states simply right-click on the first state, select “Make Transition” and drag the arrow to the next state.
Now select the arrow/transition and in the Inspector go to Conditions and add one (‘+’). Then in the list select the corresponding Trigger condition.
Finish setting up the Animator with all transitions and you are ready to use it in the interactions!
- Using Unity animations: you can animate your objects directly in Unity as well. For this select the object in the Hierarchy, then go to the Animation Window (open it if you don’t have it by default). Hit on ‘Create’, this will not only create an Animation Clip but also automatically an Animator Controller (named after your object).
- Animate your object either by recording and moving by hand or by changing the values of different Properties inside the Animation window. For details on how to Animate with Unity, click here.
For setting up your Animator follow the same steps (2-4) of the previous section “Using external clips”
For learning in deep how to use Animators and how to animate inside Unity, click here.