The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

i made 2 scenes with 2 buttons to switch between them. In the first scene there is a TextureProgress bar and my goal is to store the information of the bar value at any given time while i switch between the scenes. I made a global script and enabled it on the autoload section of the Project Settings menu, using it as singleton.

The scenes works just fine but the bar progress is not stored and remembered when i switch back from scene 2 to scene 1 where the progress bar is located.

I made some screenshots of the entire test project (it's rather small) and i'm here to ask if someone can help me understand what i'm doing wrong and why the progress bar value isn't stored and remembered. Thank you all.

in Engine by (33 points)

1 Answer

+1 vote
Best answer

I don't see you reading value of bar1 in your script. I only see you writing to it.

Read bar1 in _ready() and use it, unless it's null.

by (2,308 points)
selected by

Hi, thank you for your answer. Could you be so kind to write me down a code sample? I tried but i really don't know how to correctly read and use bar1 on _ready() section of the code. It would be so helpful to me since i'm trying to make this work since January 2018 (i know it's almost unbelievable but it's the truth).


func _ready():
    # code you already have in _ready()

    if global.bar1 != null:
        get_node("TextureProgress").set_value( global.bar1 )

Thank you so much! I want you to know that you made my day. All is working now and i can finally proceed to make my little idle game project working as intended. ^^

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 Frequently asked questions and 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 [email protected] with your username.