Im trying to make an infinite world generation with different layers of parallax backgrounds to make it feel more alive. But whenever i try instancing a child inside of a parallax background, they dont exactly end up in the same spot, rather than the first 3 tries which run when the games opened for the first time. Instead, they seem to skip a few tiles and this amount seems to be fixed for all layers. This works if i dont instance the children inside of a parallax background and anywhere else, but im unsure if theres a way to achieve the same effect without using them.

	for layer in 3:
		var background = load("res://world/plates/backgrounds/full/Background" + str(layer + 1) + "Full.tscn")
		var bg_instance = background.instance()
		get_parent().get_node("ParallaxBackground/ParallaxLayer" + str(layer + 1)).add_child(bg_instance)
		bg_instance.global_position.x = gvar.step * plate_margin

For context only the "scale" variable is different on each 3, being 1, 0.5 and 0.75 respectively. Again it works if i put them anywhere else, and it even seems to return to the right position when i print its global position out, but how do i fix this "visual" issue?

Each layer needs to be a child the ParallaxBackground by itself. In the code you are making them a child of an existing layer, which is likely the issue.

@cybereality said: Each layer needs to be a child the ParallaxBackground by itself. In the code you are making them a child of an existing layer, which is likely the issue.

I managed to find a way to get it work! If i just set the position releative to the node rather than the global position it works out perfectly! im aware it wont work on all cases the main reason it worked now is how everything is located, but it works perfectly now! thank you for the help regardless ill note that for the future!

Yeah, I don't like global position for this very reason. I've never used it, it just seems to create bugs.

10 months later