- Home /
Gap between 'seamless' parallax background
I have two planes forming my parallax background. They are position above each other and scroll from the top to the bottom over the y-axis.
The first pass is ok because I positioned them in the editor so that there is no space between them.
However, the second pass there is a gap between them. They are not joined together anymore.
The third pass is perfect again (maybe because they are back in the original starting position?)
And then it switches between gap - no gap - gap - no gap - ...
If I increase the speed, the gaps get bigger.
This script is attached to both planes:
using UnityEngine;
using System.Collections;
public class ParallaxHolder : MonoBehaviour {
public float speed;
void Update () {
float amountToMove = speed * Time.deltaTime;
transform.Translate( Vector3.down * amountToMove, Space.World );
if( transform.position.y < -50 ){
transform.position = new Vector3( transform.position.x, 130, transform.position.z );
}
}
}
How can i fix this?
PS: I've also tried the parallax script from Purdyjo's (http://purdyjotut.blogspot.be/2011/02/building-game-in-unity-part-2-basic.html), because it takes the 'current' location and object size into account. But it has the same behaviour
Answer by Pablo_Venegas451 · Nov 21, 2020 at 03:20 PM
I know it's been many years but I have a solution for that specific script, maybe it can help others.
Move the Translate piece of code after the condition where you set the new position
Your answer
![](https://koobas.hobune.stream/wayback/20220613113355im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Strumpy Parallax Shader 2 Answers
renderer.material.mainTextureOffset based on player movement 0 Answers
How to make a portal effect texture? 2 Answers
Does Unity Provide a Built-In Tessellation Shader? 0 Answers
Layered Sprite 3D effect 1 Answer