The steps are the same for 2D or 3D.
If your GameObject has an Animator component, add a Set Animator State On Dialogue Event component. If you're using the legacy Animation system, Set Animation On Dialogue Event component is for .
When using an Animator, the State Name should match the name of a state in your Animator Controller.
Note: If this state has an immediate transition to a different state, then Set Animator State On Dialogue Event will appear to not take effect, since the transition will immediately change it to a different state. Similarly, if another script such as a character controller updates the Animator, it could switch the character to a different state. In this case, you can add a Set Component Enabled On Dialogue Event component to disable the character controller.
Some Animator Controllers immediately transition based on the values of parameters such as "speed". Unity's Standard Assets 3D ThirdPersonController is a good example of this. If you use Set Animator State On Dialogue Event to change to the Idle state while the character is moving, the Animator Controller will immediately transition back to walking/running because the speed parameter is non-zero. The solution in this case is to add a Start Sequence On Dialogue Event component instead, and set the Sequence field to something like:
Code: Select all
AnimatorFloat(Speed, 0)
Code: Select all
AnimatorFloat(Speed, 0)@0.1