Godot Version
3.5
Question
Hello, I collected several general questions about objects in GD-Script.
I’m quite new to Godot (and this forum) and have some programming skills but not much. I have a little project and it grows bigger. It is a simulation. So I thought about restructuring it and am not sure which objects to choose for what purpose. It’s a thick fog I don’t see through.
Please excuse misused words, I’m non-nativ-writer.
What I Understood:
I won’t use the real object because I don’t have any clue about managing memory.
So:
Reference would be fine for serializable objects,
Ressource for nonserialized Data,
Node if I need some of those special node-features.
1.) Resource ist very good for saving. So I thought it would be useful to store all saveable Data in resources. Does that make sense? Saveable Data would be: Personal Stats of the player, the map (a tilemap), stats of cities and NPCs.
An example: when I have a NPC, which has multiple instances of it: let say bears wandering around the map and I want to save the bears and their bear-stats. My first thought would be: use a bear-node which stores the stats and instanciate it for every bear I need. Or would it be more wise to make the bear of a reference-object. And store all those bear-object-instances in an array, placed in a resource. And the node and it’s instances are only for visual representation (they bear no stats and are not needed to be saved because they can recreated while loading the saved data.
-
Grouping objects is only possible for nodes. Is there a similar opportunity for other objects? I found it quite handy to cycle through all objects of a group and can think of many purposes for it.
-
Is it possible to create a resource on runtime? Based on a reference-object? I don’t have any current use for it, I just wondered.
-
I saw people using „class_name“ on top of their resource-objects. What sense does that make if a resource cannot be serialized?
-
Autoload should be avoided. But I wondered: As far as I understood it is possible to access any object from any other object via path or similar. So what difference does it make if I can acces it anyways? E.G.: If I can load my resource in any other node it’s quite similar to autoload, isn’t it? But probably I missed a point.
-
A question about memory: I have a reference-object „TileStats“ that stores all the information of a tile (what landscape, height, population…) and a lot of functions, proceeding those data. And I have lots of instances of TileStats. I wondered if every instance of that object would use memory-space for the functions? Or if the functions would be stored „central“ and called from every instance. In the first place it would be memory saving to out-sorce those functions.
Thank you very much for reading this essay. If you could give me answers to one or two questions I would be very joyfull.`