Меню

Animator is not playing an animatorcontroller ошибка

My animator doesn’t work: I set a bool variable from code:

animatedObject.myAnimator.SetBool("MyVariable", true);
animatedObject.SetActive(true);

But the animation isn’t triggered. I’m sure that the animator’s transition is correctly set to react with «MyVariable».

Looking at the output console, I see that I have a warning:

animator is not playing an animation controller

What does that mean?

asked Mar 9, 2018 at 21:38

Basile Perrenoud's user avatar

Basile PerrenoudBasile Perrenoud

4,0013 gold badges29 silver badges52 bronze badges

The warning is not really helpful but what it means is that the AnimationController is disabled, or is on an inactive object. It will not be able to set variable since it currently doesn’t have a state.

Simply inverting the two lines, so that the animator is on an active object, will solve it:

animatedObject.SetActive(true);
animatedObject.myAnimator.SetBool("MyVariable", true);

answered Mar 9, 2018 at 21:38

Basile Perrenoud's user avatar

Basile PerrenoudBasile Perrenoud

4,0013 gold badges29 silver badges52 bronze badges

The warning Animator is not playing an AnimatorController also appears, when the Animator somehow lost the reference to the Animator Controller asset.

You can see it here in screenshot, where the Animator value for Controller is «None».
Just drag in the missing Animator Controller asset from your project view.

Missing Animator Controller

answered Mar 9, 2018 at 23:26

JeanLuc's user avatar

Tezr0

0 / 0 / 0

Регистрация: 13.09.2022

Сообщений: 1

1

13.09.2022, 15:34. Показов 365. Ответов 1

Метки unity (Все метки)


Привет всем читающим. Я новичок в юнити. Делаю игру битва башен. Столкнулся с проблемой «animator is not playing an AnimatorController». После призыва скелета(префаб) он идёт вперёд все спокойно, он стреляет и когда враг попадает в триггер который висит на скелете он стреляет во врага, при попадании происходит эта ошибка «animator is not playing an AnimatorController». В инспекторе все указано.

Скрипт скелета:

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
public class Skelet_meh : MonoBehaviour
{
    public Animator animka;
 
    public Health Enemy_Health;
 
    public Rigidbody2D rb;
 
    public GameObject Castle_Red;
    public GameObject Collision_Obj;
    public GameObject Spawner_arrow;
    public GameObject Arrow;
 
    public float Speed = 1;
 
    public int HP = 10;
    public int Damage = 2;
    public int storona = 1;
 
    private Castle_Red Castle_Red_Script;
 
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        Castle_Red_Script = Castle_Red.GetComponent<Castle_Red>();
    }
 
    void Update()
    {
        rb.velocity = new Vector2(storona * Speed, rb.velocity.y);
    }
 
    public void TriggerEnter()
    {
        animka.SetBool("Attack", true);
        Speed = 0; 
    }
 
    public void Spawn_arrow()
    {
        animka.SetBool("Wait", true);
        animka.SetBool("Attack", false);
 
        Instantiate(Arrow, Spawner_arrow.transform.position, Quaternion.identity);
    }
 
    public void ZeroHp()
    {
        animka.SetBool("Wait", false);
        animka.SetBool("Attack", false);
 
        Speed = 1;
    }
 
    public void NotZeroHp()
    {
        animka.SetBool("Wait", false);
        animka.SetBool("Attack", true);
    }
}
Стрелы:
public class Arrow_meh : MonoBehaviour
{
    public Skelet_meh Skelet_script;
    public Health Enemy_health;
    public Skelet_trigger_meh Skelet_trigger_Script;
 
    public GameObject Skelet;
    public GameObject Skelet_trigger;
 
    public int storona = 1;
    public int enemy_hp;
 
    public float Speed = 0.1f;
 
    void OnEnable()
    {
        Skelet_script = Skelet.GetComponent<Skelet_meh>();
    }
 
    private void FixedUpdate()
    {
        transform.position = transform.position + new Vector3(Speed, 0, 0);
    }
 
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.gameObject.tag == "Red")
        {
            Enemy_health = collision.gameObject.GetComponent<Health>();
            Enemy_health.Hit_Damage(Skelet_script.Damage);
 
            enemy_hp = Enemy_health.HP;
 
            Arrow_Conflict();
        }
    }
 
    public void Arrow_Conflict()
    {
        if(enemy_hp <= 0)
        {
            Skelet_script.ZeroHp();
        }
        else
        {
            Skelet_script.NotZeroHp();
        }
 
        Destroy(this.gameObject);
    }
}
Триггера:
public class Skelet_trigger_meh : MonoBehaviour
{
    public Skelet_meh Skelet_script;
 
    public GameObject Skelet;
    public GameObject Skelet_arrow;
    void Start()
    {
        Skelet_script = Skelet.GetComponent<Skelet_meh>();
    }
 
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Red")
        {
            Skelet_script.TriggerEnter();
        }
    }
 
    private void OnTriggerExit2D(Collider2D collision)
    {
        Skelet_script.animka.SetBool("Wait", false);
        Skelet_script.animka.SetBool("Attack", false);
 
        Skelet_script.Speed = 1;
    }
}

Ошибка animator is not playing an AnimatorController

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Мой аниматор не работает: я установил переменную типа bool из кода:

animatedObject.myAnimator.SetBool("MyVariable", true);
animatedObject.SetActive(true);

Но анимация не запускается. Я уверен, что переход аниматора правильно настроен на реакцию с «MyVariable».

Глядя на консоль вывода, я вижу предупреждение:

аниматор не воспроизводит контроллер анимации

Что это значит?

2 ответа

Лучший ответ

Предупреждение не очень полезно, но оно означает, что AnimationController отключен или находится на неактивном объекте. Он не сможет установить переменную, так как в настоящее время у нее нет состояния.

Простое инвертирование двух линий, чтобы аниматор находился на активном объекте, решит эту проблему:

animatedObject.SetActive(true);
animatedObject.myAnimator.SetBool("MyVariable", true);


2

Basile Perrenoud
9 Мар 2018 в 21:38

Предупреждение Animator is not playing an AnimatorController также появляется, когда Animator каким-то образом теряет ссылку на ресурс Animator Controller.

Вы можете увидеть это здесь, на снимке экрана, где значение Animator для Controller равно «None». Просто перетащите недостающий ресурс Animator Controller из представления проекта.

Missing Animator Controller


2

JeanLuc
9 Мар 2018 в 23:26

Unity 5.6, Spine & Spine-Unity runtime 3.6

Used SkeletonAnimator instead of SkeletonAnimation in scene, and encountered the error:

Animator is not playing an AnimatorController
UnityEngine.Animator:get_layerCount()

The controller is the default one; I didn’t change it, simply set the clips up. There’s only the base layer and no parameters used.
Hmmm…what did I do wrong? I tried google this error, but seems it’s relatively rare. :think:

Thanks!

Сообщение 5.5 years ago

Lavennin
  • Сообщения: 1



TedNindo

I am having the same warnings. A lot of them. Quite sure they are new so I am not sure why they pop up.

I am using the runtime version 3.6.x.x Since this thread is over 8 months old I think I should have the fixed version.

Animator is not playing an AnimatorController
UnityEngine.Animator:get_layerCount()
Spine.Unity.MecanimTranslator:Apply(Skeleton) (at Assets/spine-unity/SkeletonAnimator.cs:161)
Spine.Unity.SkeletonAnimator:Update() (at Assets/spine-unity/SkeletonAnimator.cs:78)

The link above is dead so I can’t fix it myself-

Сообщение 4.5 years ago

TedNindo
  • Сообщения: 46

Pharan

Did the warnings appear just now? What changed?

Are you using the latest? This should be included in the unitypackage by now.

Spine Unity Download

Сообщение 4.5 years ago

Аватара пользователя
Pharan
  • Сообщения: 5366
  • Сайт

TedNindo

Thanks, Pharan,
I updated once more, as it seems I did not have the very last version of the runtime libs. Seems as if the errors are gone. Thanks a lot.

Сообщение 4.5 years ago

TedNindo
  • Сообщения: 46

wayward_ed

I’ve just started using Spine (great software package!), and I’m seeing these same warnings with the latest unity runtime (the one dated 4/25).

Animator is not playing an AnimatorController
UnityEngine.Animator:get_layerCount(Animator)
Spine.Unity.MecanimTranslator:Apply(Skeleton) (at Assets/ImportedPackages/Spine/spine-unity/Components/SkeletonAnimator.cs:180)
Spine.Unity.SkeletonAnimator:Update() (at Assets/ImportedPackages/Spine/spine-unity/Components/SkeletonAnimator.cs:82)

They don’t happen all the time, but every now and then I’ll do something in the editor that tickles this and causes these to appear when I make any changes to the scene. If I run the game and then drop back into edit mode, they go away for a while, but they always seem to come back.

Сообщение 4.5 years ago

wayward_ed
  • Сообщения: 1

Dmitriy Makeyev

The guys have already passed a year, many updates have been released. Warning that was a year ago and remained.

Animator is not playing an AnimatorController
UnityEngine.Animator:get_layerCount()
Spine.Unity.MecanimTranslator:Apply(Skeleton) (at Assets/Spine/spine-unity/SkeletonAnimator.cs:139)
Spine.Unity.SkeletonAnimator:Update() (at Assets/Spine/spine-unity/SkeletonAnimator.cs:82)

Jungle Town «Birthday quest»

Сообщение 4 years ago

Аватара пользователя
Dmitriy Makeyev
  • Сообщения: 48

Pharan

This was supposed to be already fixed in the latest version.
If you are seeing this in the latest version, do you have a repro case you can send to us?

unity@esotericsoftware.com

Сообщение 4 years ago

Аватара пользователя
Pharan
  • Сообщения: 5366
  • Сайт

dcheglakov

Dmitriy Makeyev писал(а):The guys have already passed a year, many updates have been released. Warning that was a year ago and remained.

Animator is not playing an AnimatorController
UnityEngine.Animator:get_layerCount()
Spine.Unity.MecanimTranslator:Apply(Skeleton) (at Assets/Spine/spine-unity/SkeletonAnimator.cs:139)
Spine.Unity.SkeletonAnimator:Update() (at Assets/Spine/spine-unity/SkeletonAnimator.cs:82)

Hey, try to remove Spine from Unity completely and re-import again. This helped me.

Сообщение 4 years ago

dcheglakov
  • Сообщения: 1

Dmitriy Makeyev

Removed, set again. At first, I was told that there were zero warnings, but then again, at once, 500 — 600 messages of the following content:

spine-unity-3_7-2019-04-27

Animator is not playing an AnimatorController
UnityEngine.Animator:get_layerCount()
Spine.Unity.MecanimTranslator:Apply(Skeleton) (at Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs:222)
Spine.Unity.SkeletonMecanim:Update() (at Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs:85)

Jungle Town «Birthday quest»

Сообщение 3.5 years ago

Аватара пользователя
Dmitriy Makeyev
  • Сообщения: 48

Harald

Thanks for reporting the problem. We have just fixed the issue, it will be released together with the next unitypackages.

I will let you know as soon as it is available for download.

The unitypackages are now ready for download:

Spine Unity Download

Сообщение 3.5 years ago

Аватара пользователя
Harald
Harri
  • Сообщения: 4451


Вернуться в Unity

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Angry birds 2 ошибка подключения лагерь орла
  • Andy the operation was canceled 10 ошибка