How do I store choices in character option screen so the chosen character can instance in the world?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hellothere

I don’t understand how to store the choices and instance the chosen character in a world. I have a character selection screen with 2 buttons. If one of them is pressed I want that character to instance in the world. I need help in this area since I am new to storing and saving data in godot. Some feedback would be appreciated!

:bust_in_silhouette: Reply From: Inces

You propably mean, that You change whole scene after choices are done. There always must exist a code structure, that is unchanged throughout whole project. A lot of people use Autoload as a structure to hold and menage data. Choosing something in menu should set certain variables in Autoload, and when scene is changed Autoload should feed this data wherever needed. So read about Autoload, singletons.

Alright thanks, but do I just have to save the characters’ scenes and instance them or do I put both the characters as a direct child of my levels?

hellothere | 2021-10-09 01:44

Also what lines of code would be useful?

hellothere | 2021-10-09 03:41

Wow, now I have trouble understanding what is supposed to happen in your game :slight_smile:

Your character scene will contain a lot of important data about its mechanics in game, collisions, controls, stats and so on. This is not needed in character selection screen. When You choose character in menu You only need his visuals and description. So You shouldn’t use character scene in menu, You should use simple node with the same sprite and animations as your character, but much simpler script. In this script You will only have : when clicked save character type and name to Autoload and start new game.

Next, when your main game starts, it will have code line in ready() : instance new character of type Autoload.type and

Inces | 2021-10-09 16:03