parallax and scene changing issue

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By torohaifisch

hello everyone,
i am having a weird problem, i have 2 scenes (the first one has a parallax background), i have it set up so the player can move touchs something and it switches to scene 2 then he can go back to scene 1 at the same position he left but when he does that parallax background position is changed, i didnt code anything related to the parallax nodes so i dont really know why is it changing positions.

I have the same issue and not found a solution yet :frowning:

twinpixel | 2019-08-13 21:37

I have the exact same issue…

I don’t understand the problem !

cmzx | 2020-07-29 13:48

:bust_in_silhouette: Reply From: twinpixel

I found a workaround for the problem by adding the following script to the ParallaxBackground:

var layer_positions : PoolVector2Array

func _exit_tree():
	layer_positions.resize(0) #clear the array
	for b in self.get_children():
        #add parallax layer position to the array
		layer_positions.append( b.position ) 

func _enter_tree():
	for idx in layer_positions.size():
		self.get_child(idx).motion_offset = -1 * layer_positions[idx]
:bust_in_silhouette: Reply From: cmzx

I found the solution : you just have to close the scene, restard godot and it works…

If it does it again, just close it again !