Problem with time on scrolling texture

Hi. I’ve got a script:

var scrollSpeed = 0.25;

function FixedUpdate() 
{
    var offset = Time.time * scrollSpeed;
    renderer.material.mainTextureOffset = Vector2(0,offset);
}

The problem is that I have the script on an object that is instantiated while playing, so the offset is bigger if you create the object later in the game.

I’m sure I missed something but I don’t know how to fix it. Please help.

Create your own timer or you can subtract the start time:

var scrollSpeed = 0.25;
private var startTime = 0.0;

function Start() {
  startTime = Time.time;
}
 
function FixedUpdate()  {
    var offset = (Time.time - startTime) * scrollSpeed;
    renderer.material.mainTextureOffset = Vector2(0,offset);
}