+1 vote

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.

asked Aug 5, 2018 in Engine by torohaifisch (51 points)

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

I have the exact same issue...

I don't understand the problem !

1 Answer

0 votes

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]
answered Aug 14, 2019 by twinpixel (184 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.