- Home /
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???
Thanks!!
Answer by Pipioca · May 21, 2016 at 04:34 PM
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.
Your answer
Follow this Question
Related Questions
3D Background Effect And Dynamic Parallax 1 Answer
How to make infinite moving clouds 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Moving object top to down 2 Answers