Topic was automatically imported from the old Question2Answer platform.
Asked By
Amateur.game.dev.
Could someone please provide me some example script which I would need to save the character?
I know how singletons work, but I don’t know what I should write in the global.gd script which I have for the game. I have created a basic character generation system, and I’m guessing that I will require to save all separate aspects of the player (e.g. name, hair, hair colour, gender etc).
save the aspects into variables, then store them in a dictionary
example
var Hair
var Arm
var parts = { ‘Hair’: ‘Style 2’, ‘Arm’ :’ Style 5’}
load():
Hair = parts[“Hair”] #setting the global variables to match the stored information
Arm = parts[‘Arm’]
Then save your dictionary to json, there are many tutorials on youtube on how to save and load Json. hope that helps.
is the load(): a function or supposed to be in func _ready(): ?
Amateur.game.dev. | 2021-01-14 20:32
Presumably you call it whenever you want to load a character. So if you want to load them right away, it will be in _ready(). And if you want multiple characters that the player can choose when to load, you can call it whenever that happens.
exuin | 2021-01-14 20:39
I only want the player to appear in specific scenes, so how would I do this?
Amateur.game.dev. | 2021-01-14 23:09
Try putting the player into the specific scene’s node tree
Asthmar | 2021-01-14 23:22
The character is saved as an instance in the character creator, that’s how I edit it.