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

Play the list of animations

Discussion in 'Scripting' started by GizmoBradwell, Oct 5, 2012.

  1. GizmoBradwell

    GizmoBradwell

    Joined:
    Dec 27, 2010
    Posts:
    67
    How do I write a script that SIMPLY just auto plays through all animations contained in the animations Element array when I start the scene? Element 0, 1, 2, 3, 4...

    Something like this?

    Code (csharp):
    1.  
    2.  function Start () {
    3.               animation.PlayQueued("all", QueueMode.PlayNow);      
    4. }
    5.  
     
  2. GizmoBradwell

    GizmoBradwell

    Joined:
    Dec 27, 2010
    Posts:
    67
    No one can hazard a guess?
     
  3. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    You're on the right track with function Start() and PlayQueued(). You should probably use a for loop as well. Here's something of what it would look like:

    Code (csharp):
    1. function Start () {
    2.    for (var state : AnimationState in animation)
    3.       animation.PlayQueued (state.name);
    4. }
     
    Last edited: Oct 5, 2012