• 2D
  • Infinite Background

So i Have this image ! and i want to make an inffinite background out of it. like the background in this game : but I don't know how. Can someone help me please?

Welcome to the forums @sushidev!

You can have a TextureRect node, assign the texture to it, and then in the inspector there should be a drop down property, I think called mode, that you should be able to set to repeat, which will make it repeat/tile. Then it will be repeated like you expect.

To make it scroll/repeat endlessly as the player moves, I’m not sure on a great solution right off, but a possible solution would be to use a shader and pass the player’s position as a uniform, then adjust the UV by the uniform. Something like this (untested):

shader_type canvas_item;
uniform vec2 player_position = vec2(0, 0);
uniform float position_mod = 0.05;
func fragment() {
	COLOR = texture(TEXTURE, UV + (player_position * position_mod));
}

Then you just need to pass the player’s position to the shader in GDScript by getting the material and setting the shader parameter. This QA answer has an example on how to set a shader parameter from code.

Edit: It looks like the ParallaxBackground node has some built-in functionality for repeating endless backgrounds, so that may be worth looking into.

For the shader solution I think you might want to subtract the player position so the background would move in the opposite direction. But I'd look into the ParralaxBackground solution first.