0 votes

Basically, there are 3 characters that you have to choose from in the character creation scene. To choose one, you click on the texturebutton (no texture), which takes you to another scene where you change the name and class (class is not yet implemented). But I would also like the button to emit a signal to the game scene so that it displays the character that you chose.

in Engine by (298 points)

1 Answer

0 votes

You'll probably need to use an autoloaded scene / singleton. This is a scene that is essentially "global" in that is loaded when the game is first run and doesn't restart when switching scenes.

The docs explain it pretty well:

To do this, make a new script by clicking "script" > 'File" > "New Script..." in the editor. I name mine "Globals" usually. Then click on "Project" > "Project Settings" and click on the "AutoLoad" tab. Then, click the little file icon and select the "Globals" script you just made, and then click "add". Now you can access this script from any other scene/script just by typing the name of the script.

For your purpose, I would go into the global script and make a new var class = null. Then in your first scene, when the player chooses their class, you do Globals.class = self.class. Finally, in the next scene, you would do onready var class = Globals.class and then you could set_text(class) on a label to display the class.

by (594 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 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 webmaster@godotengine.org with your username.