0 votes

Hey guys,

Hopefully, someone will be able to help me out. So right now I have a Sprite with the customized beard (beard is being represented as Sprite inside of Sprite, from this tutorial - https://www.youtube.com/watch?v=Lh2H-O5-VAo&t=220s ). The player can select one out of 3 options. I would like to present the Sprite that the player has selected with the specific beard in a different scene. I will leave a code that I have right now. Thanks and have a good day.

CODE EXAMPLE --- https://imgur.com/gA9BAjn

asked Mar 9 in Projects by HashTag (29 points)

1 Answer

+1 vote
Best answer

The right answer probably depends on the details of your project. Without knowing more, one way to do it would be:

  • Create a Singleton script to maintain global game state
  • Add a variable to that script to store your selected beard information
  • Once the beard has been selected, store it in the singleton script
  • Change scenes
  • In the new scene, retrieve the stored beard value from the singleton script
answered Mar 9 by jgodfrey (6,522 points)
selected Mar 10 by HashTag

This is a very frequent question which keeps getting asked in various ways. Here is another one with some info about singletons: https://godotengine.org/qa/63642/possible-variable-value-assigned-across-different-scenes

I see. Thanks a lot for your help!

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.