Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question what tf is an array

Discussion in 'Animation' started by yumarissa, Dec 27, 2022.

  1. yumarissa

    yumarissa

    Joined:
    Dec 16, 2022
    Posts:
    2
    hey guys as you can tell im a raging beginner
    I was following this flappy bird tutorial but couldn't understand how an 'array' can be used to animate
    what is an array
    pls no hate

    Code (CSharp):
    1.     private void AnimateSprite()
    2.     {
    3.         spriteIndex++;
    4.         if (spriteIndex >= sprites.Length)
    5.         {
    6.             spriteIndex = 0;
    7.         }
    8.  
    9.         spriteRenderer.sprite = sprites[spriteIndex];
    10.  
    11.     }
    also what's sprites.Length

    thank you so much
     
    Last edited: Dec 27, 2022
  2. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    661
  3. yumarissa

    yumarissa

    Joined:
    Dec 16, 2022
    Posts:
    2