0 votes

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).

Godot version 3.2.3
in Engine by (292 points)
edited by

1 Answer

0 votes

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.

by (611 points)

is the load(): a function or supposed to be in func _ready(): ?

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.

I only want the player to appear in specific scenes, so how would I do this?

Try putting the player into the specific scene's node tree

The character is saved as an instance in the character creator, that's how I edit it.

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.
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.