Godot Reset position smoothly and loop

Godot Version

4.3

Question

I want to reset my "backgrouund_tile " position and make it loop . Its working but the it creates a snap effects which is not good to watch extends Node2D
@export var pole:PackedScene
@onready var bird: RigidBody2D = $bird
@export var background:PackedScene
@onready var backgrouund_tile: Node2D = $Backgrouund_tile

@export var max_y=100
@export var min_y=-100
var gl:Vector2
var background_width: float = 0

Called when the node enters the scene tree for the first time.

func _ready() → void:

gl=backgrouund_tile.global_position

Called every frame. ‘delta’ is the elapsed time since the previous frame.

func _process(delta: float) → void:

if backgrouund_tile.global_position.x==-400:
	backgrouund_tile.global_position.x=gl.x

print(backgrouund_tile.global_position)

func _on_timer_timeout() → void:
spawn()
func spawn()->void:

	var new_pole=pole.instantiate()
	new_pole.global_position.x=bird.global_position.x+600
	new_pole.global_position.x+=50
	new_pole.global_position.y=randf_range(min_y,max_y)
	add_child(new_pole)

Hi :wave:,

Do youm think of something like a parallax background, or do I get something wrong.

Here are a few examples:

Not really. My character can only jump and crouch.its an endless game so for that i want the illusion that my character is moving by just moving the background so far it works if i make it unlimited it just legs ( i know why) so i wanted that my background just goes left to right and after a some position it just resets . So far it works but kind of looks like it just snaps not making it smooth

Ahh ok. I understand. Maybe you should use a shader based solution?

When “moving” your character you imply scroll speed via shader param and the background should move smoothly - provided you designe the background with seamless edges.

Did my last post help?