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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Type `UnityEngine.Animator' does not contain a definition for `PlayQueued'

Discussion in 'Scripting' started by kalinova828, Aug 12, 2015.

  1. kalinova828

    kalinova828

    Joined:
    Aug 7, 2015
    Posts:
    4
    For some reason, Animation.Play() works, but Animation.PlayQueued() gives me:

    "error CS1061: Type `UnityEngine.Animator' does not contain a definition for `PlayQueued' and no extension method `PlayQueued' of type `UnityEngine.Animator' could be found (are you missing a using directive or an assembly reference?)"

    Any thoughts about what I'm doing wrong? Thanks in advance!

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class TestScript : MonoBehaviour {
    5.     public Animator TestAnimator;
    6.     string paramName;
    7.  
    8.     void Start () {
    9.         TestAnimator = GetComponent<Animator>();
    10.     }
    11.  
    12.     void Update () {
    13.         Test ();
    14.     }
    15.  
    16.     void Test(){
    17.         if (Input.anyKeyDown) {
    18.             Debug.Log ("Testing...");
    19.             TestAnimator.Play ("animation1");
    20.             TestAnimator.PlayQueued ("animation2", QueueMode.CompleteOthers);
    21.             Debug.Log("Done!");
    22.         }
    23.  
    24.     }
    25. }
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    Animator is a different class from Animation. Animator is for mecanim, and Animation is for legacy animations.

    Animation.PlayQueued exists.

    Animator.PlayQueued does not.
     
  3. kalinova828

    kalinova828

    Joined:
    Aug 7, 2015
    Posts:
    4
    Is there anything that approximates PlayQueued within Mecanim that I could use instead?
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  5. kalinova828

    kalinova828

    Joined:
    Aug 7, 2015
    Posts:
    4
    I got it working using a coroutine and WaitForSeconds. Wish there was a better way to do it, though. Whatever works, I guess?