Hello to all, I need you to solve a question I have, why I get the error shown in the following image when I run my game from the main menu and how can I make the levels can also run from the main menu?
If I’m not mistaken, this is related to get_node(…), because when trying to get a node, the method returns null. Maybe you have specified the node get wrong and you should check if the nodes are bound to each other. You can also try using get_parent, get_owner, get_child methods to get to the right node.
Short description:
get_parent gets the parent of the node
get_owner gets the topmost parent of all nodes, the root of the scene.
get_child gets the child node by its index, i.e. how it is located in the scene tree (top to bottom)
You are going to have to find out what is in node_data["parent"].
It clearly isn’t what you think it is (and we have no way of knowing) so try printing it out and see what it actually is. print(node_data["parent]")
I am guessing its going to print null, so you need to find out why that dictionary entry is not getting written.
It is giving me a value that does not exist, in the console it says the following message: /root/Level1, level 1 is actually in the project folder, and that is where it should be loaded from or from the user folder, but not from the root folder, could you tell me how to do that? Because it is really not recommended to use plugins to make save and load game systems.
Yes, it is necessary, because I need to save the player’s points, this player’s position and the player’s lives, but can that be done with the plugin you told me?
then just save the player points, position and lives data, no need to save whole running nodes of it
in the example implementation, i showed how to save the “slime” HP, max HP, global position. other variable can be just added too. without needing to save whole slime’s scene’s data
Oh, wow, I saw that all that was done in a YouTube tutorial, but now I don’t understand how I can save the character’s position without having to go to its root node?
you can download it from asset Library tab on your godot editor
search “save” and it should pop up for you, just download then enable it
click view files to see the official documentation of how it’s used, but if you want a pretty basic example of how to use it, check what i have sent following the plugin link
Be active and there it works alone? Although I do not think so, I asked him where is the information on how to implement it in the code? Ah, thank you very much!
One question, how can I define what things I want to save in the plugin script, I found an empty dictionary in the plugin script, but for example I could not access the exact position of the player by putting elements inside that dictionary.
Hello again, other question, why when I load the data saved in the file, only the points and lives are loaded but not the coordinates of my character? I need also to save those coordinates, because I did it as follows SaveSystem.set_var("x_pos", position.x) in my character’s script once the game window was closed (the same line of code I used for the y_pos and putting after the comma position.y), I really don’t know how to do that, because I saved all the necessary data you told me.
because the save files is saved in JSON, which mean saving vector will just become string, you will need to convert it back to vector2 by yourself when loading the position. so from string to vector2. some ppl made a conversion for it like https://www.reddit.com/r/godot/comments/4t25y1/string_to_vector2/
or simply you can just save the position in 2 “key” position x and y, that’s what i’ve shown in the example implementation. then when loading it, you put it in new Vector2 the x and y