Animator does not have animator controller

I am trying to use a C# script to play an animation clip associated with a state starting from some time instance. This snippet of code called in the Update() function throws the error : “Animator does not have animator controller”.

        Animator animator = GetComponent<Animator> ();
        var controller = (AnimatorController)animator.runtimeAnimatorController;
        UnityEditor.Animations.AnimatorStateMachine sm = controller.layers[0].stateMachine;
        per_clip_count ++;

        float time_var = (float) per_clip_count / (float) (ListLength[clip_index]);
        print("sequence time : "+ time_var);

        animator.Play(state_name, -1, time_var);
1 Like

Does your animator have an animator controller? Look in the inspector at the GameObject where your Animator is located, and look at the Controller slot.