Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Parameters

Parameter Description
resetParameters Set to true to also reset the controller parameters to their default values. When set to false, only the controller state is reset.

Description

Resets the AnimatorController to its default state.

Use this method to reset the layers in the AnimatorController to their default state.

using UnityEngine;

// Press the Spacebar in Play Mode to reset the animator to the default state

[RequireComponent(typeof(Animator))]
public class AnimatorResetExample : MonoBehaviour
{
    // The Animator component on the GameObject this script is attached to.
    Animator m_Animator;

    void Start()
    {
        m_Animator = GetComponent<Animator>();
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            //This will reset the animator to the default state.
            m_Animator.ResetControllerState();
        }
    }
}