Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Bug Animator is not playing Animator Controller error.

Discussion in 'Animation' started by shurikenplayz123, Mar 9, 2023.

  1. shurikenplayz123

    shurikenplayz123

    Joined:
    Oct 24, 2020
    Posts:
    6
    I am remaking pong and I have powerups that play a stretch animation making the players longer. When I try to trigger the animation using OnTriggerEnter2d it says the error "Animator is not playing Animator Controller error". Does anybody know a solution to this problem?
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Animations;
    5.  
    6. public class animateTarget : MonoBehaviour
    7. {
    8.     public Animator Anim;
    9.     private bool start = false;
    10.     public float lifeTime = 5;
    11.     public float lifeTimeCounter = 0;
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.         Anim.gameObject.SetActive(true);
    17.         Anim.GetComponent<Animator>();
    18.      
    19.     }
    20.     void Update()
    21.     {
    22.         if (lifeTimeCounter > lifeTime)
    23.         {
    24.             Destroy(gameObject);
    25.         }
    26.         lifeTimeCounter = lifeTimeCounter + Time.deltaTime;
    27.     }
    28.     // Update is called once per frame
    29.     private void OnTriggerEnter2D(Collider2D collision)
    30.     {
    31.         if (collision.gameObject.CompareTag("Ball") && !start)
    32.         {
    33.             Debug.Log("penis");
    34.             Anim.SetBool("start", true);
    35.          
    36.  
    37.  
    38.         }
    39.  
    40.     }
    41. }
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599