Setting the Runtime Animator Controller Back to Default

Hi,
Based on the content of this lecture if you want to set the Runtime Animator Controller to an Animator Override Controller here is a sample script. However how would you program setting the Runtime Animator Controller back to the default one? How do you reference it?

public class Controller : MonoBehaviour
{
    public Animator animator;
    public AnimatorOverrideController animatorOverrideController;

    Start()
{
    animator = GetComponent<Animator>();
}

    Update()
{
    if (Input.GetKey(Keycode.Space))
    {
        animator.runtimeAnimatorController = animatorOverrideController;
    }
    if (Input.GetKey(KeyCode.Tab))
    {
        // Set the runtime animator controller to the default one
    }
}

Thank you

If by default, you mean the controller that the animator started with at the start of the game, you’d need to get a reference to the controller in the beginning.

RuntimeAnimatorController defaultController;
void Start()
{
    animator = GetComponent<Animator>();
    defaultController = animator.runtimeAnimatorController;
}

Thanks a lot

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms