Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ResetControllerState(bool)

Resets the AnimatorController to its default state.
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.AnimationModule
public void ResetControllerState(bool resetParameters = true)

Parameters

resetParameters

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

Remarks

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

Examples

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(); } }}