Quick Tip: Stopping Characters During Conversations
Posted: Fri Nov 10, 2017 4:57 pm
This is a supplement to the manual's PC/NPC setup sections on SetEnabled Components.
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:
Or, if the controller script works in LateUpdate, you may need to delay that command by a short amount such as 0.1 second:
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