Hi,
So I got a 3 layered parallax background working thanks to Brady, and the background moves smoothly enough for now (Sprite Manager 1), but there is a small problem… When the image is repositioned to rescroll there is a slight gap between the sprites…I dont know why this happens as i think the calculations in the code seem fine:
The sprites are of size 480 x 320 and im positioning them at 240f and 720f… Totally stumped.
void Update () {
((GameObject)BgQuads[0]).transform.Translate(Vector3.left * 100 * Time.deltaTime);
((GameObject)BgQuads[1]).transform.Translate(Vector3.left * 100 * Time.deltaTime);
if(((GameObject)BgQuads[0]).transform.position.x<-240f){
((GameObject)BgQuads[0]).transform.position = new Vector3(720f,((GameObject)BgQuads[0]).transform.position.y,((GameObject)BgQuads[0]).transform.position.z);
}
if(((GameObject)BgQuads[1]).transform.position.x<-240f){
((GameObject)BgQuads[1]).transform.position = new Vector3(720f,((GameObject)BgQuads[1]).transform.position.y,((GameObject)BgQuads[1]).transform.position.z);
}
}
void GenerateBGQuad (int num) {
BgQuads.Add(Instantiate(BgPrefab,new Vector3(240f,160f,755f),Quaternion.identity));
BgQuads.Add(Instantiate(BgPrefab,new Vector3(720f,160f,755f),Quaternion.identity));
BgQuads.Add(Instantiate(BgPrefab,new Vector3(240f,110f,555f),Quaternion.identity));
BgQuads.Add(Instantiate(BgPrefab,new Vector3(720f,110f,555f),Quaternion.identity));
BgQuads.Add(Instantiate(BgPrefab,new Vector3(240f,60f,355f),Quaternion.identity));
BgQuads.Add(Instantiate(BgPrefab,new Vector3(720f,60f,355f),Quaternion.identity));
}
void GenerateBGSprites(){
Sprite s = bgSpriteManager.AddSprite((GameObject)BgQuads[0],480f,320f,0,512,480,320,false);
BgSprites.Add(s);
Sprite s1 = bgSpriteManager.AddSprite((GameObject)BgQuads[1],480f,320f,480,512,480,320,false);
BgSprites.Add(s1); …
Here is a screenshot for clarity:
Thanks a lot…