Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do I switch this animation with code?

Discussion in 'Scripting' started by SiMULOiD, Jan 12, 2014.

  1. SiMULOiD

    SiMULOiD

    Joined:
    Dec 23, 2013
    Posts:
    126
    Hi all,

    I'm trying to switch from one animating texture to another.
    Can you advise me how to end the current animation and switch to the next?



    Code (csharp):
    1.  
    2.  
    3. #pragma strict
    4.  
    5. function Awake () {
    6.  
    7.  
    8.       BroadcastMessage ("PrePlay");
    9.       BroadcastMessage ("PlayAnimation", 0);
    10.    
    11.       }
    12.    
    13.    
    14. // What do I enter here to switch animations to below:
    15.    
    16.    
    17.   {
    18.       BroadcastMessage ("PrePlay");
    19.       BroadcastMessage ("PlayAnimation", 1);
    20.    
    21.  
    22.    }
    23.  
    24.  
    25.  
    26.  
    27.