Animated Texture doesn't begin at first frame

Hi, I’ve been having this problem several times over several projects. I use the Extended Animated Texture script from here

Problem is: I instantiate prefabs with this script, but the animation won’t always start at the first frame. Anyone has any idea how to prevent this?

going off of your first link, the problem lies with this line:

	var index : int = Time.time * fps;

Time.time goes off of the time the game started, what you want is to start with zero… to do this ,we can zero out the individual time on creation… just change/add the lines:

    var framesPerSecond = 1.0;
    var myStart : float;  //add this line

  function Start(){
    myStart = Time.time;   //add this

  function Update(){

           var index : int = (Time.time-myStart) * framesPerSecond; //change this

this way, we account for the amount of time that has passed between the game start and the creation of the object :slight_smile: