Problem with the scroll parallaxing

Hello forum!

A problem with parallax scrolling turn me crazy! I have a background with a repeat material and in the update procedure i have GetComponent<Renderer> ().material.mainTextureOffset = new Vector2 (((auxTiempo) * velocidad) % 1, 0);. All right, the background is repeat and move it correctly.

The problem is when my character and the backgrond stop it and i want restart the movement. The backgroud don’t continue the movement from where it was… give a jump.

I have this in the Update():

void Update () {		
		if (enMovimiento) {			
			//El fondo cerca se moverá si el personaje se mueve. El fondo lejos se moverá siempre
			if ((rigiPersonaje.velocity.x != 0) || (esFondoLejos)) {
				if (!parado) {
					auxTiempo = Time.time - tiempoInicio;

				GetComponent<Renderer> ().material.mainTextureOffset = new Vector2 (((auxTiempo) * velocidad) % 1, 0);
				parado = false;

			} else if ((rigiPersonaje.velocity.x == 0) && (!parado)) {
				auxTiempo = Time.time - tiempoInicio;    	
                //auxTextureOffset = GetComponent<Renderer> ().material.mainTextureOffset					
				parado = true;	

I try it too with an auxTextureOffset…

I don’t know what i do! Can anybody help me please???


I founded the solution!

The solution is add the mainTextureOff like this…

GetComponent<Renderer> ().material.mainTextureOffset += new Vector2 ((Time.deltaTime*velocidad) % 1, 0);

It may be that someone will help Solution.