Search Unity

sprite manager 2 animation control

Discussion in 'Scripting' started by lesfundi, Mar 10, 2011.

  1. lesfundi

    lesfundi

    Joined:
    Jan 10, 2009
    Posts:
    628
    I am trying to figure out how to control the animations in a script with SM2.

    here below is my script but i want to find out how or what do I need to change so the animations will play.

    Code (csharp):
    1.  
    2.  
    3.  
    4. var speed : float = 0.01;
    5. var updown : float = 0.01;
    6.  
    7. //var bird : PackedSprite;
    8.  
    9. function Update () {
    10.    
    11.   // var bird : PackedSprite = gameObject.GetComponent("PackedSprite");
    12.    
    13.     var translation : float = Input.GetAxis ("Horizontal") * speed;
    14.     var updown : float = Input.GetAxis ("Vertical") * speed;
    15.    
    16.     translation *= Time.deltaTime;
    17.     updown *= Time.deltaTime;
    18.  
    19.     transform.Translate (translation, updown , 0);
    20.    
    21.     if (translation > 0 )
    22.      {
    23.      transform.localScale = Vector3(-1,1,0);
    24.      //bird.PlayAnim(0);
    25.      }  
    26.      
    27.      else (translation < 0 )
    28.      {
    29.      transform.localScale = Vector3(1,1,0);
    30.      //bird.PlayAnim(1);
    31.      }  
    32.