// Update is called once per frame void Update() { checkPoint1 = instantiatedBgs[2].transform.position; checkPoint1 -= Vector3.right * bgWidth / 2; { GameObject firstBg = instantiatedBgs[0]; instantiatedBgs.Remove(firstBg); firstBg.transform.position += bgWidth * 3 * Vector3.right; instantiatedBgs.Add(firstBg); //checkPoint1 += bgWidth * Vector3.right; } checkPoint2 = instantiatedBgs[0].transform.position; checkPoint2 += Vector3.right * bgWidth / 2; if (player.transform.position.x < checkPoint2.x) { GameObject lastBg = instantiatedBgs[2]; instantiatedBgs.Remove(lastBg); lastBg.transform.position -= bgWidth * 3 * Vector3.right; instantiatedBgs.Insert(0, lastBg); //checkPoint1 += bgWidth * Vector3.right; } Vector3 offset = parallaxScale * player.GethorizontalSpeed() * Vector3.right; transform.position += offset; Vector3 offset2 = parallaxScale * player.GetverticalSpeed() * Vector3.up; transform.position += offset2; }