Hi!
I’m making a basic scrolling effect for the ground and background. It moves constantly, not by user input.
When I play the game, the floor moves at the desired speed from right to left along the X axis. I want the background to then jump back around to the right of the canvas once it is out on the frame and carrying on moving left to create the infinite moving effect.
The code I’m using isn’t working. When the image reaches x -700, it is supposed to then jump back to the right of the canvas but it isn’t. I have tried with and without the “transform.position.z” on the vector3 part and it doesn’t change anything. Any help would be greatly appreciated!
public class grassScroller : MonoBehaviour
{
void Update()
{
transform.position += new Vector3(-0.005f, 0);
if (transform.position.x < -700)
{
transform.position = new Vector3(660, transform.position.y);
}
}
}