im making a game and i tried to implement a save system using resources. it saves a few variables, but also all of the coins as packed scenes with this script:
var coins = get_tree().get_nodes_in_group("collectable")
for collectable in coins:
var cointhing = PackedScene.new()
cointhing.pack(collectable)
globalvariables.save_file_1.coins_i_think.append(cointhing)
saving a few times makes the save file very big, which makes the game lag. does anybody know how to fix it?
Saving packed scenes is not the best way to implement a save system.
What you need to do is to store a variable in the coin scene that stores if has been collected. When instantiating the coin, just check the ‘collected’ variable related to that particular coin to determine if to spawn it or not.
Here’s an article from Godot on Saving Games. You can also check out the lengthy write-up I did in this thread on how to implement the exact thing you’re looking for:
its not really what i was looking for, since i’m doing the save system with resources. is there a way of saving each coin’s collected variable in one resource?
ok so i didnt really get it and ended up saving the coins name in an array in the save file resource whenever its collected, and when the level is loaded, the coin checks if its name is there. it seems to work. thanks for help anyways!