hi Guys i created a script which makes my sprite move, what i did is i created an texture array which hold my sprite images i know i should use a sprite sheet but i dont like it that way, anyways what i want to do is when Unity runs i want the sprite to run automatically. I want my array to cycle through the number of elements within the array and once it has reached to the end i want it to restart. I have created a function at the bottom and that's where i want the code written in and then i want to call it on the start function here is my script:

the array that hold the images is var idleFrames : Texture [];


var MoveSpeed : float = 5;

var CurrentFrame: int =0;

var jumping: boolean = false;

var altTerryTexture : Texture[];

var TerryIdleTexture: Texture [];

var idleFrames : Texture [];

function Start(){




}

function Update () {


if (Input.GetKey(KeyCode.A)){

transform.Translate(Vector3(MoveSpeed * Time.deltaTime, 0 ,0));
renderer.material.mainTexture = altTerryTexture[CurrentFrame];
}
if (Input.GetKey(KeyCode.D)){

transform.Translate(Vector3(-MoveSpeed * Time.deltaTime , 0, 0));
renderer.material.mainTexture = TerryIdleTexture[CurrentFrame];

}

}