0 votes

i am working at a space shooter and when I switch scenes between the title screen and the main game scene the parallax background reset (background is instacieted scene in both title and main game). itried this:

Main game.gd

func _ready():
    Global.world = self

    for item in Global.star_type:
        match item:
            "Big":
                $HUD/ParallaxBackground/big_stars.position = Global.big_position
            "Small":
                $HUD/ParallaxBackground/small_stars.position =Global.small_position

func set_position(value):
    set("position",value)

Singleton.gd

var star_type =["Big","Small"]
var big_position 
var small_position

Title screen.gd

func _on_Start_pressed():

    for item in Global.star_type:
        match item:
            "Big":
                Global.big_position = $Game_UI/ParallaxBackground/big_stars.get("motion_offset")
            "Small":
                Global.small_position = $Game_UI/ParallaxBackground/small_stars.get("motion_offset")
    get_tree().change_scene("res://Scene/World/World.tscn")

any way to make iti work?

Godot version v3.2.3 stable.official
in Engine by (47 points)

Please log in or register to answer this question.

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.